Skip to content

Commit a62cfff

Browse files
authored
refactor: structure of lambda code (#3224)
1 parent 43acb08 commit a62cfff

File tree

109 files changed

+9388
-14926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+9388
-14926
lines changed

.ci/Dockerfile

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
#syntax=docker/dockerfile:1.2
2-
FROM node:16 as build
3-
WORKDIR /lambda
2+
FROM node:18 as build
3+
WORKDIR /lambdas
44
RUN apt-get update \
55
&& apt-get install -y zip \
66
&& rm -rf /var/lib/apt/lists/*
77

8-
FROM build as runner-binaries-syncer
9-
COPY modules/runner-binaries-syncer/lambdas/runner-binaries-syncer /lambda
10-
RUN --mount=type=cache,target=/lambda/node_modules,id=runner-binaries-syncer \
11-
yarn install && yarn dist
12-
13-
FROM build as runners
14-
COPY modules/runners/lambdas/runners /lambda
15-
RUN --mount=type=cache,target=/lambda/node_modules,id=runners \
16-
yarn install && yarn dist
17-
18-
FROM build as webhook
19-
COPY modules/webhook/lambdas/webhook /lambda
20-
RUN --mount=type=cache,target=/lambda/node_modules,id=webhook \
21-
yarn install && yarn dist
8+
FROM build as lambdas
9+
COPY lambdas /lambdas
10+
RUN --mount=type=cache,target=/work/node_modules,id=lambdas \
11+
yarn install --frozen-lockfile && yarn dist && \
12+
find . -name "*.zip" -exec cp {} . \;
2213

2314
FROM scratch as final
24-
COPY --from=runner-binaries-syncer /lambda/runner-binaries-syncer.zip /runner-binaries-syncer.zip
25-
COPY --from=runners /lambda/runners.zip /runners.zip
26-
COPY --from=webhook /lambda/webhook.zip /webhook.zip
15+
COPY --from=lambdas /lambdas/*.zip /

.ci/build-yarn.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/lambda-runner-binaries-syncer.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/lambda-runners.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/lambda-webhook.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/lambda-template.yml renamed to .github/workflows/lambda.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Lambda Syncer
1+
name: Build lambdas
22
on:
3-
workflow_call:
4-
inputs:
5-
working-directory:
6-
required: true
7-
type: string
3+
pull_request:
4+
branches:
5+
- main
6+
paths:
7+
- 'lambdas/**'
88

99
jobs:
1010
build:
@@ -16,12 +16,12 @@ jobs:
1616
image: node:${{ matrix.node }}
1717
defaults:
1818
run:
19-
working-directory: ${{ inputs.working-directory }}/${{ inputs.image }}
19+
working-directory: ./lambdas
2020

2121
steps:
2222
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
2323
- name: Install dependencies
24-
run: yarn install
24+
run: yarn install --frozen-lockfile
2525
- name: Run prettier
2626
run: yarn format-check
2727
- name: Run linter

.github/workflows/release.yml

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ on:
55
- main
66
- v1
77
workflow_dispatch:
8+
89
jobs:
9-
prepare:
10-
name: Create dist
10+
release:
11+
name: Release
1112
runs-on: ubuntu-latest
1213
container: node:18
13-
strategy:
14-
matrix:
15-
lambda: ["modules/webhook/lambdas/webhook", "modules/runner-binaries-syncer/lambdas/runner-binaries-syncer", "modules/runners/lambdas/runners"]
1614
permissions:
17-
contents: read
15+
contents: write
1816
actions: write
1917
steps:
2018
- name: Extract lambda name
@@ -26,21 +24,8 @@ jobs:
2624
- name: Add zip
2725
run: apt update && apt install zip
2826
- name: Build dist
29-
working-directory: ${{ matrix.lambda }}
27+
working-directory: lambdas
3028
run: yarn install && yarn run test && yarn dist
31-
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # ratchet:actions/upload-artifact@v3
32-
with:
33-
name: ${{ steps.lambda.outputs.name }}
34-
path: ${{ matrix.lambda }}/${{ steps.lambda.outputs.name }}.zip
35-
retention-days: 1
36-
release:
37-
name: release
38-
runs-on: ubuntu-latest
39-
needs: prepare
40-
outputs:
41-
releases_created: ${{ steps.release.outputs.releases_created }}
42-
tag_name: ${{ steps.release.outputs.tag_name }}
43-
steps:
4429
- name: Get installation token
4530
uses: philips-software/app-token-action@a37926571e4cec6f219e06727136efdd073d8657 # ratchet:philips-software/[email protected]
4631
id: token
@@ -59,23 +44,11 @@ jobs:
5944
default-branch: ${{ steps.branch.outputs.name }}
6045
release-type: terraform-module
6146
token: ${{ steps.token.outputs.token }}
62-
assets:
63-
name: upload assets
64-
if: ${{ needs.release.outputs.releases_created }}
65-
needs: release
66-
runs-on: ubuntu-latest
67-
strategy:
68-
matrix:
69-
asset: ["webhook", "runner-binaries-syncer", "runners"]
70-
permissions:
71-
contents: write
72-
actions: read
73-
steps:
74-
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # ratchet:actions/checkout@v3
75-
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
76-
with:
77-
name: ${{ matrix.asset }}
7847
- name: Upload Release Asset
48+
if: ${{ steps.release.outputs.releases_created }}
7949
env:
8050
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81-
run: gh release upload ${{ needs.release.outputs.tag_name }} ${{ matrix.asset }}.zip
51+
run: |
52+
for f in $(find . -name '*.zip'); do
53+
gh release upload ${{ needs.release.outputs.tag_name }} $f
54+
done

.github/workflows/terraform.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
uses: actions/checkout@v3
2828
- name: "Fake zip files" # Validate will fail if it cannot find the zip files
2929
run: |
30-
touch modules/webhook/lambdas/webhook/webhook.zip
31-
touch modules/runners/lambdas/runners/runners.zip
32-
touch modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/runner-binaries-syncer.zip
30+
touch lambdas/functions/webhook/webhook.zip
31+
touch lambdas/functions/control-plane/runners.zip
32+
touch lambdas/functions/gh-agent-syncer/runner-binaries-syncer.zip
3333
- name: terraform init
3434
run: terraform init -get -backend=false -input=false
3535
- if: contains(matrix.terraform, '1.3.')

.vscode/settings.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
{
2-
"sonarlint.rules": {
3-
"javascript:S4123": {
4-
"level": "off"
5-
}
6-
}
7-
}
1+
{}

0 commit comments

Comments
 (0)