Skip to content

Commit

Permalink
Merge pull request #2567 from philips-labs/next
Browse files Browse the repository at this point in the history
chore: Add support multi-runners #2517
  • Loading branch information
npalm authored Dec 28, 2022
2 parents 0d2b294 + 5919612 commit 8e8c644
Show file tree
Hide file tree
Showing 140 changed files with 3,885 additions and 3,478 deletions.
4 changes: 2 additions & 2 deletions .ci/build-yarn.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env bash -e

# Build all the lambda's, output on the default place (inside the lambda module)

Expand All @@ -7,5 +7,5 @@ repoRoot=$(dirname $(dirname $(realpath ${BASH_SOURCE[0]})))

for lambdaDir in ${lambdaSrcDirs[@]}; do
cd "$repoRoot/${lambdaDir}"
yarn && yarn run dist
yarn && yarn run all && yarn run dist
done
8 changes: 8 additions & 0 deletions .github/lint/tflint.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
aws_region = null
github_app = {
id = "0"
key_base64 = "0"
webhook_secret = "0"
}
subnet_ids = []
vpc_id = null
25 changes: 3 additions & 22 deletions .github/workflows/lambda-runner-binaries-syncer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,6 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16]
container:
image: node:${{ matrix.node }}
defaults:
run:
working-directory: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install
- name: Run prettier
run: yarn format-check
- name: Run linter
run: yarn lint
- name: Run tests
run: yarn test
- name: Build distribution
run: yarn build
uses: ./.github/workflows/lambda-template.yml
with:
working-directory: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer
29 changes: 3 additions & 26 deletions .github/workflows/lambda-runners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16]
container:
image: node:${{ matrix.node }}
defaults:
run:
working-directory: modules/runners/lambdas/runners

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install
- name: Run prettier
run: yarn format-check
- name: Run linter
run: yarn lint
- name: Run tests
run: yarn test
- name: Run two tests in isolation
run: |
yarn run test src/scale-runners/scale-up.test.ts -t 'scaleUp with GHES on org level creates a runner with labels in s specific group' --coverage=false
yarn run test src/scale-runners/scale-up.test.ts -t 'scaleUp with public GH on org level creates a runner with labels in s specific group' --coverage=false
- name: Build distribution
run: yarn build
uses: ./.github/workflows/lambda-template.yml
with:
working-directory: modules/runners/lambdas/runners
32 changes: 32 additions & 0 deletions .github/workflows/lambda-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lambda Syncer
on:
workflow_call:
inputs:
working-directory:
required: true
type: string

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18]
container:
image: node:${{ matrix.node }}
defaults:
run:
working-directory: ${{ inputs.working-directory }}/${{ inputs.image }}

steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
- name: Install dependencies
run: yarn install
- name: Run prettier
run: yarn format-check
- name: Run linter
run: yarn lint
- name: Run tests
run: yarn test
- name: Build distribution
run: yarn build
25 changes: 3 additions & 22 deletions .github/workflows/lambda-webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,6 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16]
container:
image: node:${{ matrix.node }}
defaults:
run:
working-directory: modules/webhook/lambdas/webhook

steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install
- name: Run prettier
run: yarn format-check
- name: Run linter
run: yarn lint
- name: Run tests
run: yarn test
- name: Build distribution
run: yarn build
uses: ./.github/workflows/lambda-template.yml
with:
working-directory: modules/webhook/lambdas/webhook
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
prepare:
name: Create dist
runs-on: ubuntu-latest
container: node:16
container: node:18
strategy:
matrix:
lambda: ["modules/webhook/lambdas/webhook", "modules/runner-binaries-syncer/lambdas/runner-binaries-syncer", "modules/runners/lambdas/runners"]
Expand Down
48 changes: 44 additions & 4 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ on:
paths-ignore:
- "modules/*/lambdas/**"

permissions:
contents: read
pull-requests: write

env:
AWS_REGION: eu-west-1
jobs:
verify_module:
name: Verify module
strategy:
matrix:
terraform: [1.1.3, "latest"]
terraform: [1.3.2, "latest"]
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:${{ matrix.terraform }}
Expand All @@ -28,7 +32,7 @@ jobs:
touch modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/runner-binaries-syncer.zip
- name: terraform init
run: terraform init -get -backend=false -input=false
- if: contains(matrix.terraform, '1.1.')
- if: contains(matrix.terraform, '1.3.')
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
- if: contains(matrix.terraform, 'latest') # check formatting for the latest release but avoid failing the build
Expand All @@ -37,13 +41,21 @@ jobs:
continue-on-error: true
- name: validate terraform
run: terraform validate
- if: contains(matrix.terraform, '1.3.')
name: Setup TFLint
uses: terraform-linters/setup-tflint@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- if: contains(matrix.terraform, '1.3.')
name: Run TFLint
run: tflint -f compact

verify_examples:
name: Verify examples
strategy:
fail-fast: false
matrix:
terraform: [1.0.11, 1.1.3, "latest"]
terraform: [1.3.0, "latest"]
example:
["default", "ubuntu", "prebuilt", "arm64", "ephemeral", "windows"]
defaults:
Expand All @@ -56,7 +68,7 @@ jobs:
- uses: actions/checkout@v3
- name: terraform init
run: terraform init -get -backend=false -input=false
- if: contains(matrix.terraform, '1.1.')
- if: contains(matrix.terraform, '1.3.')
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
- if: contains(matrix.terraform, 'latest') # check formatting for the latest release but avoid failing the build
Expand All @@ -65,3 +77,31 @@ jobs:
continue-on-error: true
- name: validate terraform011
run: terraform validate


verify_multi_runner_example:
name: Verify Multi-Runner examples
strategy:
fail-fast: false
matrix:
terraform: [1.3.2, "latest"]
defaults:
run:
working-directory: examples/multi-runner
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:${{ matrix.terraform }}
steps:
- uses: actions/checkout@v3
- name: terraform init
run: terraform init -get -backend=false -input=false
- if: contains(matrix.terraform, '1.3.')
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
- if: contains(matrix.terraform, 'latest') # check formatting for the latest release but avoid failing the build
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
continue-on-error: true
- name: validate terraform
run: terraform validate

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.52.0
rev: v1.76.0
hooks:
- id: terraform_fmt
- id: terraform_tflint
- id: terraform_docs
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: check-merge-conflict
7 changes: 7 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
config {
format = "compact"
module = true

varfile = [".github/lint/tflint.tfvars"]

}
Loading

0 comments on commit 8e8c644

Please sign in to comment.