Skip to content

Commit

Permalink
chore: documentation and code improvements (#1035)
Browse files Browse the repository at this point in the history
* chore: Bump aws-sdk (#752) (#909)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#908)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#887)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#885)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#889)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#892)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#907)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#864)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump eslint in /modules/webhook/lambdas/webhook (#918)

Bumps [eslint](https://github.com/eslint/eslint) from 7.28.0 to 7.29.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.28.0...v7.29.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump typescript (#929)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.3.3...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump @typescript-eslint/eslint-plugin (#928)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump typescript in /modules/webhook/lambdas/webhook (#926)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.3.3...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: Added support for white listing of repositories (#915)

* add white listing of repositories

Signed-off-by: ravenolf <benahmed@soramitsu.co.jp>

* fix variable naming

Signed-off-by: ravenolf <benahmed@soramitsu.co.jp>

* add unit test

* update docs

* add successful unit test

Co-authored-by: ravenolf <benahmed@soramitsu.co.jp>

* chore(examples): Upgrade default example to terraform 1.x.x

* chore(doc): Remove org level admin permission #801

Org level admin permissions for the app are not required any more, removed from docs.

* feat: make delay of webhook event configurable (#990)

* fix: change module exports and upgrade vercel to latest release (#1005)

* bugfix: change module exports and upgrade vercel to latest release

* bugfix: webhook.verify is now asynchronous

* fix: reduce permission required for session manager (#1018)

* feat: Store lambda secrets paramaters in Paramater Store (#941)

* fix(scale): Refactor Runner Type and Owner (#871)

* fix(scale): Refactor Runner Type and Owner

* `environment` should not be optional

* feat: support multiple instance types (#898)

* fix(scale): Refactor Runner Type and Owner

* `environment` should not be optional

* feat(runners): Support Multiple Instance Types

* Correcting failed launch logic

* Updating tests

* Test for all launch templates failing

* Marking `instance_type` as deprecated

* docs: fix lambda_security_group_ids incorrect description #738 (#902)

close #738

* fix: scale down runners (#905)

* fix: scale down runners

* fix: scale down runners

* chore: group upgrade lambda dependencies (#906)

* chore: upgrade dependencies for lambda's

* fix auth-app to 3.4.0, issues #904 addresses the issue

* feat(runner): Move Lambda Vars to Parameter Store

* Add test for ssm module (#1)

* Add test for ssm module

* Fixing lint

* Removing KMS/GH Auth from scale-down

* Add SSM permissions to runner policy

* Allow custom key_id

* Fixing for loop

* Move SSM policy to Lambdas

* Fixing function call

* chore: Bump aws-sdk (#752) (#909)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#908)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#887)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#885)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#889)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#892)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#907)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump aws-sdk (#752) (#864)

Bumps [aws-sdk](https://github.com/aws/aws-sdk-js) from 2.863.0 to 2.888.0.
- [Release notes](https://github.com/aws/aws-sdk-js/releases)
- [Changelog](https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-js@v2.863.0...v2.888.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump eslint in /modules/webhook/lambdas/webhook (#918)

Bumps [eslint](https://github.com/eslint/eslint) from 7.28.0 to 7.29.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.28.0...v7.29.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump typescript (#929)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.3.3...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump @typescript-eslint/eslint-plugin (#928)

Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.27.0 to 4.28.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.28.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: Bump typescript in /modules/webhook/lambdas/webhook (#926)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v4.3.3...v4.3.4)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: Added support for white listing of repositories (#915)

* add white listing of repositories

Signed-off-by: ravenolf <benahmed@soramitsu.co.jp>

* fix variable naming

Signed-off-by: ravenolf <benahmed@soramitsu.co.jp>

* add unit test

* update docs

* add successful unit test

Co-authored-by: ravenolf <benahmed@soramitsu.co.jp>

* Need `,` after list item

* Move Lambda Policy to data resource

* Addressing PR comments, fixing lint

* Refactoring Parameters to SSM Module

* Fixing rebase

* Using only key ARN as input value

Co-authored-by: Niek Palm <npalm@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sofiane Benahmed <38732323+ravenolf@users.noreply.github.com>
Co-authored-by: ravenolf <benahmed@soramitsu.co.jp>

* feat: Adding support for new workflow_job event. (#1019)

Added support for new workflow_job event, the check_run event will remain for backwards compatibility

* chore: Bump @types/node in /modules/webhook/lambdas/webhook

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.14.7 to 16.4.12.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: Bump tar from 4.4.13 to 4.4.15 in /.release

Bumps [tar](https://github.com/npm/node-tar) from 4.4.13 to 4.4.15.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v4.4.13...v4.4.15)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: Bump jest-mock-extended in /modules/runners/lambdas/runners

Bumps [jest-mock-extended](https://github.com/marchaos/jest-mock-extended) from 1.0.18 to 2.0.1.
- [Release notes](https://github.com/marchaos/jest-mock-extended/releases)
- [Commits](https://github.com/marchaos/jest-mock-extended/commits)

---
updated-dependencies:
- dependency-name: jest-mock-extended
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: Bump @types/node

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 15.14.7 to 16.4.12.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: handle situation of no prereleases correctly, and propagate lambda error to caller.

* chore (doc): small improvements

* fix: wait for scaleDown to have finished before calling callback

Wait for scaleDown to have executed before returning to the caller that no error occurred.

* chore: code consistency and improvements

- use question mark after field name i.s.o. Type | undefined
- use more functional approach i.s.o. for-loops
- import all items from a single dependency on a single line
- remove unused imports
- add missing return type to function
- change payload type from any to string

* fix: tests were not always correct or incomplete or duplicate

- add test for terminateRunner
- removed duplicate tests for scale-down
- use assertions consistently -> ".not" changed to ".not.toBeCalled()"
- set process.env.ENABLE_ORGANIZATION_RUNNERS before calling scaleDown, and assert the right call to have been called
- remove "Once" from the paginate  mock, as it is called more than once
- fix inconsistent asserts for both repo and org functions in the scaleUp tests
- remove expectedRunnerParams field overriding when they are already overridden to same value at a higher level
- add test for all launches failing in the repo level tests
- add test for decryption failing in hte websocket handler
- add checking of the payload to the SQS request
- change the X-Github-Event to "check_run" to really test what was intended to be tested

* fix: use consistent reporting back to caller

* chore(release): 0.15.1 [skip ci]

* apply patch for broken scale up lambda [#980](#980) ([b957e26](b957e26))

* Update CHANGELOG

* fix: CONTRIBUTION.md should refer develop iso master branch

* Cleanup

* Incorporate review comments and fix build issue

* Update modules/runners/README.md

Co-authored-by: Gertjan Maas <gertjan@maas.codes>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sofiane Benahmed <38732323+ravenolf@users.noreply.github.com>
Co-authored-by: ravenolf <benahmed@soramitsu.co.jp>
Co-authored-by: Niek Palm <niek.palm@philips.com>
Co-authored-by: Niek Palm <npalm@users.noreply.github.com>
Co-authored-by: PatrickMennen <PatrickMennen@users.noreply.github.com>
Co-authored-by: Nathaniel McAuliffe <nmcauliffe@expediagroup.com>
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
Co-authored-by: Gertjan Maas <gertjan@maas.codes>
  • Loading branch information
10 people authored Aug 11, 2021
1 parent 153d699 commit dd2c2d8
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 144 deletions.
36 changes: 18 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

We'd love for you to contribute to our source code and to make the Forest even better than it is today! Here are the guidelines we'd like you to follow:

- [Question or Problem?](#question)
- [Issues and Bugs](#issue)
- [Feature Requests](#feature)
- [Submission Guidelines](#submit)
- [Further Info](#info)
* [Question or Problem?](#question)
* [Issues and Bugs](#issue)
* [Feature Requests](#feature)
* [Submission Guidelines](#submit)
* [Further Info](#info)

## <a name="question"></a> Got a Question or Problem?

Expand All @@ -27,7 +27,6 @@ You can request a new feature by submitting an issue to our [Github Repository][
* **Major Changes** that you wish to contribute to the project should be discussed first on our [Slack group][slack] so that we can better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project.
* **Small Changes** can be crafted and submitted to the [Github Repository][github] as a Pull Request.


## <a name="docs"></a> Want a Doc Fix?

If you want to help improve the docs, it's a good idea to let others know what you're working on to minimize duplication of effort. Create a new issue (or comment on a related existing one) to let others know what you're working on.
Expand All @@ -37,6 +36,7 @@ For large fixes, please build and test the documentation before submitting the M
## <a name="submit"></a> Submission Guidelines

### Submitting an Issue

Before you submit your issue search the archive, maybe your question was already answered.

If your issue appears to be a bug, and hasn't been reported, open a new issue. Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues. Providing the following information will increase the chances of your issue being dealt with quickly:
Expand All @@ -58,18 +58,18 @@ Before you submit your merge request consider the following guidelines:
* Make your changes in a new git branch:

```shell
git checkout -b my-fix-branch master
git checkout -b my-fix-branch develop
```

* Create your patch, **including appropriate test cases**.
* Run the test suite and ensure that all tests pass.
* Add a line in the CHANGELOG.md under Unreleased. This will be used form generating the release notes.
* Install [pre-commit hooks](https://pre-commit.com/). The hooks runs some basic checks and update the docs. The commit will run the hooks, you can invoke the hooks manually `pre-commit run --all-files` as well.
* Commit your changes using a descriptive commit message.

```shell
git commit -a
```

Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.

* Build your changes locally to ensure all the tests pass:
Expand All @@ -79,7 +79,7 @@ Before you submit your merge request consider the following guidelines:
git push origin my-fix-branch
```

In Github, send a pull request to original master branch: f.e. `terraform-aws-vpc:master`.
In Github, send a pull request to original develop branch: f.e. `terraform-aws-vpc:develop`.
If we suggest changes, then:

* Make the required updates.
Expand All @@ -89,10 +89,10 @@ If we suggest changes, then:

If the PR gets too outdated we may ask you to rebase and force push to update the PR:

```shell
git rebase master -i
git push origin my-fix-branch -f
```
```shell
git rebase develop -i
git push origin my-fix-branch -f
```

_WARNING: Squashing or reverting commits and force-pushing thereafter may remove Github comments on code that were previously made by you or others in your commits. Avoid any form of rebasing unless necessary._

Expand All @@ -109,10 +109,10 @@ from the main (upstream) repository:
git push origin --delete my-fix-branch
```
* Check out the master branch:
* Check out the develop branch:
```shell
git checkout master -f
git checkout develop -f
```
* Delete the local branch:
Expand All @@ -121,10 +121,10 @@ from the main (upstream) repository:
git branch -D my-fix-branch
```
* Update your master with the latest upstream version:
* Update your develop with the latest upstream version:
```shell
git pull --ff upstream master
git pull --ff upstream develop
```
## <a name="info"></a> Info
Expand All @@ -136,5 +136,5 @@ Use the badge to sign-up.
[![Slack](https://philips-software-slackin.now.sh/badge.svg)](https://philips-software-slackin.now.sh)
[contribute]: CONTRIBUTING.md
[github]: https://github.com/philips-lam/terraform-aws-github-runner/issues
[github]: https://github.com/philips-labs/terraform-aws-github-runner/issues
[slack]: https://philips-software.slack.com/home
4 changes: 2 additions & 2 deletions examples/default/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Action runners deployment default example

This modules shows how to create GitHub action runners. Lambda release will be downloaded from GitHub.
This module shows how to create GitHub action runners. Lambda release will be downloaded from GitHub.

## Usages

Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simple remove the location of the lambda zip files, the default location will work in this case.
Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case.

> Ensure you have set the version in `lambdas-download/main.tf` for running the example. The version needs to be set to a GitHub release version, see https://github.com/philips-labs/terraform-aws-github-runner/releases
Expand Down
4 changes: 2 additions & 2 deletions examples/permissions-boundary/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Action runners deployed with permissions boundary

This modules shows how to create GitHub action runners with permissions boundaries and paths used in role, policies, and instance profiles.
This module shows how to create GitHub action runners with permissions boundaries and paths used in role, policies, and instance profiles.

## Usages

Steps for the full setup, such as creating a GitHub app can be find the module [README](../../README.md). First create the deploy role and boundary policies. This steps required an admin user.
Steps for the full setup, such as creating a GitHub app can be find the module [README](../../README.md). First create the deploy role and boundary policies. These steps require an admin user.

> Ensure you have set the version in `lambdas-download/main.tf` for running the example. The version needs to be set to a GitHub release version, see https://github.com/philips-labs/terraform-aws-github-runner/releases
Expand Down
4 changes: 2 additions & 2 deletions examples/ubuntu/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Action runners deployment ubuntu example

This modules shows how to create GitHub action runners using an Ubuntu AMI. Lambda release will be downloaded from GitHub.
This module shows how to create GitHub action runners using an Ubuntu AMI. Lambda release will be downloaded from GitHub.

## Usages

Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simple remove the location of the lambda zip files, the default location will work in this case.
Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case.

> Ensure you have set the version in `lambdas-download/main.tf` for running the example. The version needs to be set to a GitHub release version, see https://github.com/philips-labs/terraform-aws-github-runner/releases
Expand Down
2 changes: 1 addition & 1 deletion examples/ubuntu/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ terraform {
provider "aws" {
region = local.aws_region

// If you use roles with specific permissons please add your role
// If you use roles with specific permissions please add your role
// assume_role {
// role_arn = "arn:aws:iam::123456789012:role/MyAdminRole"
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { handle } from './syncer/handler';

// eslint-disable-next-line
export const handler = async (event: any, context: any, callback: any): Promise<void> => {
await handle();
callback();
try {
await handle();
callback(null);
} catch (e) {
callback(e);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,30 @@ describe('Synchronize action distribution.', () => {
expect(mockS3.upload).toBeCalledTimes(0);
});

it('Distribution is up-to-date with latest release when there are no prereleases.', async () => {
process.env.GITHUB_RUNNER_ALLOW_PRERELEASE_BINARIES = 'true';
const releases = listReleases.slice(1);

mockOctokit.repos.listReleases.mockImplementation(() => ({
data: releases,
}));
mockS3.getObjectTagging.mockImplementation(() => {
return {
promise() {
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-2.272.0.tar.gz' }] });
},
};
});

await handle();
expect(mockOctokit.repos.listReleases).toBeCalledTimes(1);
expect(mockS3.getObjectTagging).toBeCalledWith({
Bucket: bucketName,
Key: bucketObjectKey,
});
expect(mockS3.upload).toBeCalledTimes(0);
});

it('Distribution is up-to-date with latest prerelease.', async () => {
process.env.GITHUB_RUNNER_ALLOW_PRERELEASE_BINARIES = 'true';
mockS3.getObjectTagging.mockImplementation(() => {
Expand Down Expand Up @@ -95,6 +119,32 @@ describe('Synchronize action distribution.', () => {
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.272.0.tar.gz');
});

it('Distribution should update to release if there are no pre-releases.', async () => {
process.env.GITHUB_RUNNER_ALLOW_PRERELEASE_BINARIES = 'true';
const releases = listReleases.slice(1);

mockOctokit.repos.listReleases.mockImplementation(() => ({
data: releases,
}));
mockS3.getObjectTagging.mockImplementation(() => {
return {
promise() {
return Promise.resolve({ TagSet: [{ Key: 'name', Value: 'actions-runner-linux-x64-0.tar.gz' }] });
},
};
});

await handle();
expect(mockOctokit.repos.listReleases).toBeCalledTimes(1);
expect(mockS3.getObjectTagging).toBeCalledWith({
Bucket: bucketName,
Key: bucketObjectKey,
});
expect(mockS3.upload).toBeCalledTimes(1);
const s3JsonBody = mockS3.upload.mock.calls[0][0];
expect(s3JsonBody['Tagging']).toEqual('name=actions-runner-linux-x64-2.272.0.tar.gz');
});

it('Distribution should update to prerelease.', async () => {
process.env.GITHUB_RUNNER_ALLOW_PRERELEASE_BINARIES = 'true';
mockS3.getObjectTagging.mockImplementation(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function getLinuxReleaseAsset(
const latestReleaseIndex = assetsList.data.findIndex((a) => a.prerelease === false);

let asset = undefined;
if (fetchPrereleaseBinaries && latestPrereleaseIndex < latestReleaseIndex) {
if (fetchPrereleaseBinaries && latestPrereleaseIndex != -1 && latestPrereleaseIndex < latestReleaseIndex) {
asset = assetsList.data[latestPrereleaseIndex];
} else if (latestReleaseIndex != -1) {
asset = assetsList.data[latestReleaseIndex];
Expand Down Expand Up @@ -86,6 +86,7 @@ async function uploadToS3(s3: S3, cacheObject: CacheObject, actionRunnerReleaseA
});
}).catch((error) => {
console.error(`Exception: ${error}`);
throw error;
});
}

Expand Down
4 changes: 2 additions & 2 deletions modules/runners/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ This module creates resources required to run the GitHub action runner on AWS EC

### Action runners on EC2

The action runners are created via a launch template, on launch template only the subnet needs to be provided. During launch the installation is handled via a user data script. The configuration is fetched from SSM parameter store.
The action runners are created via a launch template; in the launch template only the subnet needs to be provided. During launch the installation is handled via a user data script. The configuration is fetched from SSM parameter store.

### Lambda scale up

The scale up lambda is triggered by events on a SQS queue. Events on this queued are delayed, which will will give the workflow some time to start running on available runners. For each event the lambda will check the workflow is still queued and no other limits are reached. In that case the lambda will create a new EC2 instance. The lambda only needs to know which launch template to use and which subnets are available. From the available subnets a random one will be chosen. Once the instance is created the event is assumed as handled, and we assume the workflow wil start at some moment once the created instance is ready.
The scale up lambda is triggered by events on a SQS queue. Events on this queue are delayed, which will give the workflow some time to start running on available runners. For each event the lambda will check if the workflow is still queued and no other limits are reached. In that case the lambda will create a new EC2 instance. The lambda only needs to know which launch template to use and which subnets are available. From the available subnets a random one will be chosen. Once the instance is created the event is assumed as handled, and we assume the workflow wil start at some moment once the created instance is ready.

### Lambda scale down

Expand Down
2 changes: 1 addition & 1 deletion modules/runners/lambdas/runners/src/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const scaleUp = async (event: SQSEvent, context: Context, callback: any):

export const scaleDown = async (event: ScheduledEvent, context: Context, callback: any): Promise<void> => {
try {
scaleDownAction();
await scaleDownAction();
callback(null);
} catch (e) {
console.error(e);
Expand Down
21 changes: 19 additions & 2 deletions modules/runners/lambdas/runners/src/scale-runners/runners.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { listRunners, createRunner } from './runners';
import { listRunners, createRunner, terminateRunner, RunnerInfo } from './runners';

const mockEC2 = { describeInstances: jest.fn(), runInstances: jest.fn() };
const mockEC2 = { describeInstances: jest.fn(), runInstances: jest.fn(), terminateInstances: jest.fn() };
const mockSSM = { putParameter: jest.fn() };
jest.mock('aws-sdk', () => ({
EC2: jest.fn().mockImplementation(() => mockEC2),
Expand Down Expand Up @@ -102,6 +102,23 @@ describe('list instances', () => {
});
});

describe('terminate runner', () => {
const mockTerminateInstances = { promise: jest.fn() };
beforeEach(() => {
jest.clearAllMocks();
mockEC2.terminateInstances.mockImplementation(() => mockTerminateInstances);
mockTerminateInstances.promise.mockReturnThis();
});
it('calls terminate instances with the right instance ids', async () => {
const runner: RunnerInfo = {
instanceId: 'instance-2',
};
await terminateRunner(runner);

expect(mockEC2.terminateInstances).toBeCalledWith({ InstanceIds: [runner.instanceId] });
});
});

describe('create runner', () => {
const mockRunInstances = { promise: jest.fn() };
const mockPutParameter = { promise: jest.fn() };
Expand Down
8 changes: 4 additions & 4 deletions modules/runners/lambdas/runners/src/scale-runners/runners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { EC2, SSM } from 'aws-sdk';

export interface RunnerInfo {
instanceId: string;
launchTime: Date | undefined;
repo: string | undefined;
org: string | undefined;
launchTime?: Date;
repo?: string;
org?: string;
}

export interface ListRunnerFilters {
runnerType?: 'Org' | 'Repo';
runnerOwner?: string;
environment: string | undefined;
environment?: string;
}

export interface RunnerInputParameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ const DEFAULT_IDLE_COUNT = 1;
const now = moment.tz(new Date(), 'America/Los_Angeles');

function getConfig(cronTabs: string[]): ScalingDownConfigList {
const result: ScalingDownConfigList = [];
for (const cron of cronTabs) {
result.push({
cron: cron,
idleCount: DEFAULT_IDLE_COUNT,
timeZone: DEFAULT_TIMEZONE,
});
}
return result;
return cronTabs.map((cron) => ({
cron: cron,
idleCount: DEFAULT_IDLE_COUNT,
timeZone: DEFAULT_TIMEZONE,
}));
}

describe('scaleDownConfig', () => {
Expand Down
Loading

0 comments on commit dd2c2d8

Please sign in to comment.