Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…aws-github-runner into fix/S3-tf-resource
  • Loading branch information
shashidhar087 committed Apr 13, 2022
2 parents 33d2707 + 3658d6a commit d22b3fb
Show file tree
Hide file tree
Showing 12 changed files with 1,035 additions and 880 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-approve-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2.1.0
- uses: hmarr/auto-approve-action@v2.2.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build dist
working-directory: ${{ matrix.lambda }}
run: yarn install && yarn run test && yarn dist
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.lambda.outputs.name }}
path: ${{ matrix.lambda }}/${{ steps.lambda.outputs.name }}.zip
Expand All @@ -43,15 +43,15 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: webhook
path: artifacts
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: runners
path: artifacts
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: runner-binaries-syncer
path: artifacts
Expand Down
6 changes: 3 additions & 3 deletions .release/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2252,9 +2252,9 @@ [email protected]:
kind-of "^6.0.3"

minimist@^1.2.0, minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==

minipass-collect@^1.0.2:
version "1.0.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"@vercel/ncc": "^0.33.3",
"aws-sdk": "^2.1097.0",
"aws-sdk": "^2.1112.0",
"eslint": "^7.32.0",
"eslint-plugin-prettier": "4.0.0",
"jest": "^27.5.1",
"jest-mock": "^27.5.1",
"prettier": "2.6.1",
"ts-jest": "^27.1.3",
"prettier": "2.6.2",
"ts-jest": "^27.1.4",
"ts-node-dev": "^1.1.6",
"typescript": "^4.6.2"
"typescript": "^4.6.3"
},
"dependencies": {
"axios": "^0.26.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@
source-map "^0.6.1"
write-file-atomic "^3.0.0"

"@jest/types@^27.4.2", "@jest/types@^27.5.1":
"@jest/types@^27.5.1":
version "27.5.1"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.5.1.tgz#3c79ec4a8ba61c170bf937bcf9e98a9df175ec80"
integrity sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==
Expand Down Expand Up @@ -1086,10 +1086,10 @@ asynckit@^0.4.0:
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k=

aws-sdk@^2.1097.0:
version "2.1097.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1097.0.tgz#1e53ee27d8ab7523760d023b934b24a9512bd719"
integrity sha512-fChMDiSfWcW0EUWmiqlyc+VAIXKH0w7BBruL3cVWSwO+5oA5A9juGF4NCBV2/KAHzaKaG0hXKPE49Wh6Lq74ag==
aws-sdk@^2.1112.0:
version "2.1112.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1112.0.tgz#7e6f60df562ebd909a9435b01673ed7685e10ffd"
integrity sha512-8FKr3zwD2bHZQLmxJ7d1VwvDkW9kKx4YPdNXawV+CqNUzQC/9ZmSmHyx8mZCv6J722tqxIZh5c567499QawuZw==
dependencies:
buffer "4.9.2"
events "1.1.1"
Expand Down Expand Up @@ -1907,11 +1907,6 @@ globby@^11.0.3:
merge2 "^1.3.0"
slash "^3.0.0"

graceful-fs@^4.2.4:
version "4.2.8"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a"
integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==

graceful-fs@^4.2.9:
version "4.2.9"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96"
Expand Down Expand Up @@ -2502,19 +2497,7 @@ jest-snapshot@^27.5.1:
pretty-format "^27.5.1"
semver "^7.3.2"

jest-util@^27.0.0:
version "27.4.2"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.4.2.tgz#ed95b05b1adfd761e2cda47e0144c6a58e05a621"
integrity sha512-YuxxpXU6nlMan9qyLuxHaMMOzXAl5aGZWCSzben5DhLHemYQxCc4YK+4L3ZrCutT8GPQ+ui9k5D8rUJoDioMnA==
dependencies:
"@jest/types" "^27.4.2"
"@types/node" "*"
chalk "^4.0.0"
ci-info "^3.2.0"
graceful-fs "^4.2.4"
picomatch "^2.2.3"

jest-util@^27.5.1:
jest-util@^27.0.0, jest-util@^27.5.1:
version "27.5.1"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-27.5.1.tgz#3ba9771e8e31a0b85da48fe0b0891fb86c01c2f9"
integrity sha512-Kv2o/8jNvX1MQ0KGtw480E/w4fBCDOnH6+6DmeKi6LZUIlKA5kwY0YNdlzaWTiVgxqAqik11QyxDOKk543aKXw==
Expand Down Expand Up @@ -2779,9 +2762,9 @@ minimatch@^3.0.4:
brace-expansion "^1.1.7"

minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==

mkdirp@^1.0.4:
version "1.0.4"
Expand Down Expand Up @@ -2975,10 +2958,10 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

[email protected].1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.1.tgz#d472797e0d7461605c1609808e27b80c0f9cfe17"
integrity sha512-8UVbTBYGwN37Bs9LERmxCPjdvPxlEowx2urIL6urHzdb3SDq4B/Z6xLFCblrSnE4iKWcS6ziJ3aOYrc1kz/E2A==
[email protected].2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==

pretty-format@^27.0.0, pretty-format@^27.5.1:
version "27.5.1"
Expand Down Expand Up @@ -3384,10 +3367,10 @@ tree-kill@^1.2.2:
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
integrity sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==

ts-jest@^27.1.3:
version "27.1.3"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.3.tgz#1f723e7e74027c4da92c0ffbd73287e8af2b2957"
integrity sha512-6Nlura7s6uM9BVUAoqLH7JHyMXjz8gluryjpPXxr3IxZdAXnU6FhjvVLHFtfd1vsE1p8zD1OJfskkc0jhTSnkA==
ts-jest@^27.1.4:
version "27.1.4"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.4.tgz#84d42cf0f4e7157a52e7c64b1492c46330943e00"
integrity sha512-qjkZlVPWVctAezwsOD1OPzbZ+k7zA5z3oxII4dGdZo5ggX/PL7kvwTM0pXTr10fAtbiVpJaL3bWd502zAhpgSQ==
dependencies:
bs-logger "0.x"
fast-json-stable-stringify "2.x"
Expand Down Expand Up @@ -3491,10 +3474,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4"
integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==
typescript@^4.6.3:
version "4.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"
integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==

universal-user-agent@^6.0.0:
version "6.0.0"
Expand Down
14 changes: 7 additions & 7 deletions modules/runners/lambdas/runners/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@
"eslint-plugin-prettier": "4.0.0",
"jest": "27.5.1",
"jest-mock": "^27.5.1",
"jest-mock-extended": "^2.0.1",
"jest-mock-extended": "^2.0.5",
"moment-timezone": "^0.5.34",
"nock": "^13.2.4",
"prettier": "2.6.1",
"ts-jest": "^27.1.3",
"prettier": "2.6.2",
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"ts-node-dev": "^1.1.6"
},
"dependencies": {
"@aws-sdk/client-ssm": "^3.54.1",
"@aws-sdk/client-ssm": "^3.67.0",
"@octokit/auth-app": "3.6.1",
"@octokit/rest": "^18.12.0",
"@octokit/types": "^6.34.0",
"@types/aws-lambda": "^8.10.93",
"@types/express": "^4.17.11",
"@types/node": "^17.0.23",
"aws-sdk": "^2.1100.0",
"cron-parser": "^4.2.1",
"aws-sdk": "^2.1112.0",
"cron-parser": "^4.3.0",
"tslog": "^3.3.3",
"typescript": "^4.6.2"
"typescript": "^4.6.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const mockOctokit = {
listSelfHostedRunnersForOrg: jest.fn(),
deleteSelfHostedRunnerFromOrg: jest.fn(),
deleteSelfHostedRunnerFromRepo: jest.fn(),
getSelfHostedRunnerForOrg: jest.fn(),
getSelfHostedRunnerForRepo: jest.fn(),
},
paginate: jest.fn(),
};
Expand Down Expand Up @@ -144,10 +146,14 @@ const DEFAULT_RUNNERS_ORIGINAL = [
repo: `${TEST_DATA.repositoryOwner}/${TEST_DATA.repositoryName}`,
},
{
instanceId: 'i-busy-112',
launchTime: moment(new Date())
.subtract(minimumRunningTimeInMinutes + 27, 'minutes')
.toDate(),
instanceId: 'i-running-112',
launchTime: moment(new Date()).subtract(25, 'minutes').toDate(),
type: 'Repo',
owner: `doe/another-repo`,
},
{
instanceId: 'i-running-113',
launchTime: moment(new Date()).subtract(25, 'minutes').toDate(),
type: 'Org',
owner: TEST_DATA.repositoryOwner,
},
Expand All @@ -157,37 +163,42 @@ const DEFAULT_REGISTERED_RUNNERS = [
{
id: 101,
name: 'i-idle-101',
busy: false,
},
{
id: 102,
name: 'i-idle-102',
busy: false,
},
{
id: 103,
name: 'i-oldest-idle-103',
busy: false,
},
{
id: 104,
name: 'i-oldest-idle-104',
busy: false,
},
{
id: 105,
name: 'i-running-105',
busy: false,
},
{
id: 106,
name: 'i-running-106',
busy: false,
},
{
id: 112,
name: 'i-busy-112',
busy: true,
id: 1121,
name: 'i-running-112-1',
},
{
id: 1122,
name: 'i-running-112-2',
},
{
id: 1131,
name: 'i-running-113-1',
},
{
id: 1132,
name: 'i-running-113-2',
},
];

Expand Down Expand Up @@ -235,6 +246,29 @@ describe('scaleDown', () => {
}
});

mockOctokit.actions.getSelfHostedRunnerForRepo.mockImplementation((repo) => {
if (repo.runner_id === 1121) {
return {
data: { busy: true },
};
} else {
return {
data: { busy: false },
};
}
});
mockOctokit.actions.getSelfHostedRunnerForOrg.mockImplementation((repo) => {
if (repo.runner_id === 1131) {
return {
data: { busy: true },
};
} else {
return {
data: { busy: false },
};
}
});

const mockTerminateRunners = mocked(terminateRunner);
mockTerminateRunners.mockImplementation(async () => {
return;
Expand Down Expand Up @@ -279,8 +313,7 @@ describe('scaleDown', () => {
);

RUNNERS_ALL_REMOVED = DEFAULT_RUNNERS_ORG.filter(
(r) =>
!r.instanceId.includes('running') && !r.instanceId.includes('registered') && !r.instanceId.includes('busy'),
(r) => !r.instanceId.includes('running') && !r.instanceId.includes('registered'),
);
DEFAULT_RUNNERS_ORPHANED = DEFAULT_RUNNERS_ORIGINAL.filter(
(r) => r.instanceId.includes('orphan') && !r.instanceId.includes('not-registered'),
Expand Down Expand Up @@ -349,7 +382,7 @@ describe('scaleDown', () => {
beforeEach(() => {
process.env.SCALE_DOWN_CONFIG = JSON.stringify([
{
idleCount: 2,
idleCount: 3,
cron: '* * * * * *',
timeZone: 'Europe/Amsterdam',
},
Expand Down Expand Up @@ -479,7 +512,7 @@ describe('scaleDown', () => {
beforeEach(() => {
process.env.SCALE_DOWN_CONFIG = JSON.stringify([
{
idleCount: 2,
idleCount: 3,
cron: '* * * * * *',
timeZone: 'Europe/Amsterdam',
},
Expand Down
Loading

0 comments on commit d22b3fb

Please sign in to comment.