Skip to content

Commit 7354e0b

Browse files
committed
revamp the github action workflows (#43)
* fix the preview workflow * fix * fix * test against a branch * remove the branch * fix integration test with auth token * try running on macos * setup docker on macos * run macOS tests only on schedule * remove cloud pods release workflow * reform the cloud pods action * remove keepalive workflow
1 parent 5978d86 commit 7354e0b

File tree

4 files changed

+103
-152
lines changed

4 files changed

+103
-152
lines changed

.github/workflows/cloudpod_release.yml

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

.github/workflows/integration-test.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ on:
2222
type: choice
2323
options:
2424
- ubuntu-latest
25-
- macos-latest
25+
- macos-13
2626

2727

2828
jobs:
2929
run-it-tests-job:
3030
runs-on: ${{ inputs.runner-os || 'ubuntu-latest' }}
3131
steps:
3232
- name: Checkout
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v4
3434

3535
- name: Set up Python 3.11
3636
id: setup-python
@@ -39,9 +39,9 @@ jobs:
3939
python-version: 3.11
4040

4141
- name: Docker setup (macos only)
42-
id: setup-docker-mac
4342
if: ${{ runner.os == 'macOS' }}
4443
run: |
44+
brew install colima
4545
brew install docker
4646
colima start
4747
@@ -50,14 +50,15 @@ jobs:
5050
pip install -r requirements-dev.txt
5151
5252
- name: Start LocalStack
53-
uses: LocalStack/setup-localstack@v0.2.2
53+
uses: LocalStack/setup-localstack@v0.2.4
5454
with:
5555
image-tag: 'latest'
5656
use-pro: 'true'
5757
configuration: LS_LOG=trace
5858
install-awslocal: 'true'
5959
env:
60-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
60+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
61+
6162
- name: Build lambdas
6263
run: |
6364
bin/build_lambdas.sh

.github/workflows/preview_create.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- ./*.md
88
- LICENSE
99
- .circleci/*
10-
- .gitlab-ci.yml
1110

1211
jobs:
1312
test:
@@ -30,20 +29,16 @@ jobs:
3029
pip install awscli-local
3130
3231
- name: Deploy Preview
33-
uses: LocalStack/setup-localstack@v0.2.2
32+
uses: LocalStack/setup-localstack@main
3433
env:
35-
AWS_DEFAULT_REGION: us-east-1
36-
AWS_REGION: us-east-1
37-
AWS_ACCESS_KEY_ID: test
38-
AWS_SECRET_ACCESS_KEY: test
39-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
34+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
4035
with:
4136
github-token: ${{ secrets.GITHUB_TOKEN }}
4237
state-backend: ephemeral
4338
state-action: start
44-
skip-ephemeral-stop: 'true'
4539
include-preview: 'true'
40+
install-awslocal: 'true'
4641
preview-cmd: |
4742
# Add your custom deployment commands here.
4843
# Below is an example for the Image resizer application.
49-
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
44+
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
Lines changed: 93 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,111 @@
1-
name: Test Released Cloud Pods
1+
name: Create and Test LocalStack Cloud Pod
22

33
on:
44
schedule:
5-
# At 00:00 on Saturday.
5+
# At 00:00 on Saturday.
66
- cron: "0 0 * * 6"
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
713
workflow_dispatch:
814

915
permissions:
1016
contents: write
17+
actions: read
1118

1219
jobs:
13-
get-releases:
14-
name: Retrieve Released Cloud Pods
20+
create-pod:
21+
name: Create Cloud Pod
1522
runs-on: ubuntu-latest
23+
permissions:
24+
actions: write
1625
outputs:
17-
matrix: ${{ steps.set-matrix.outputs.matrix }}
26+
pod_artifact_name: cloud-pod-${{ github.run_id }}
1827
steps:
19-
- id: set-matrix
20-
env:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
run: |
23-
output=$(gh api repos/$GITHUB_REPOSITORY/releases | jq -r '[.[] | select(.tag_name|startswith("v")|not) | .tag_name]')
24-
output=$(echo $output | tr '\n' ' ')
25-
echo "matrix=$output" >> $GITHUB_OUTPUT
26-
27-
test-pod-release:
28-
needs: get-releases
29-
runs-on: ubuntu-latest
30-
strategy:
31-
fail-fast: false
32-
matrix:
33-
tag: ${{ fromJson(needs.get-releases.outputs.matrix) }}
34-
steps:
35-
# checkout to run the tests later on
36-
- name: Checkout
37-
uses: actions/checkout@v3
28+
- name: Checkout Code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Install Dependencies
37+
run: |
38+
pip install -r requirements-dev.txt --upgrade
39+
40+
- name: Start LocalStack
41+
uses: LocalStack/setup-localstack@main
42+
with:
43+
use-pro: 'true'
44+
install-awslocal: 'true'
45+
env:
46+
DEBUG: 1
47+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
48+
49+
- name: Deploy Infrastructure (Example)
50+
run: |
51+
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
3852
39-
# Loading it manually as we're storing the state as a release and not an artifact
40-
- name: Retrieve Pod
53+
- name: Export LocalStack State (Cloud Pod)
54+
id: export_state
4155
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
4357
run: |
44-
# TODO the download url seems to follow the pattern $GITHUB_REPOSITORY/releases/download/{TAG}/{ASSET_NAME}
45-
# alternatively we can query the asset-id, and browser_download_url, but it seems like an overhead
46-
# asset_id=$(gh api repos/$GITHUB_REPOSITORY/releases/tags/latest | jq -r '.assets[]' | jq --arg DB $DB -c 'select(.name=="release-pod-\( $DB ).zip") | .id)
47-
# download_url=$(gh api repos/$GITHUB_REPOSITORY/releases/assets/$asset_id | jq -r ".browser_download_url")
48-
download_url="https://github.com/$GITHUB_REPOSITORY/releases/download/${{ matrix.tag }}/release-pod.zip"
49-
curl -L $download_url --output release-pod.zip
50-
ls -la
58+
echo "Exporting LocalStack state..."
59+
localstack state export cloud-pod.zip
60+
ls -la cloud-pod.zip # Verify the file exists
61+
echo "pod_artifact_name=cloud-pod-${{ github.run_id }}" >> $GITHUB_OUTPUT
62+
63+
- name: Upload Cloud Pod Artifact
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: ${{ steps.export_state.outputs.pod_artifact_name }}
67+
path: cloud-pod.zip
68+
retention-days: 1
69+
70+
test-pod:
71+
name: Test Cloud Pod
72+
needs: create-pod
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout Code
76+
uses: actions/checkout@v4
5177

5278
- name: Setup Python
53-
uses: actions/setup-python@v4
79+
uses: actions/setup-python@v5
5480
with:
5581
python-version: '3.11'
5682

83+
- name: Install Test Dependencies
84+
run: |
85+
pip install -r requirements-dev.txt --upgrade
86+
5787
- name: Start LocalStack
58-
uses: LocalStack/setup-localstack@v0.2.2
88+
uses: LocalStack/setup-localstack@main
5989
with:
60-
image-tag: ${{ matrix.tag }}
6190
use-pro: 'true'
6291
install-awslocal: 'true'
6392
env:
6493
DEBUG: 1
6594
POD_LOAD_CLI_TIMEOUT: 300
66-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
95+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
96+
97+
- name: Download Cloud Pod Artifact
98+
uses: actions/download-artifact@v4
99+
with:
100+
name: ${{ needs.create-pod.outputs.pod_artifact_name }}
67101

68-
- name: Inject Pod
102+
- name: Inject Pod (Import State)
69103
env:
70-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
104+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
71105
run: |
72-
localstack state import release-pod.zip
106+
echo "Importing LocalStack state from cloud-pod.zip..."
107+
ls -la # Check if download was successful
108+
localstack state import cloud-pod.zip
73109
74110
- name: Run Tests
75111
env:
@@ -78,11 +114,10 @@ jobs:
78114
AWS_ACCESS_KEY_ID: test
79115
AWS_SECRET_ACCESS_KEY: test
80116
run: |
81-
pip install -r requirements-dev.txt
82117
pytest tests
83118
84-
- name: Show Logs
85-
if: failure()
119+
- name: Show LocalStack Logs
120+
if: always()
86121
run: |
87122
localstack logs
88123
@@ -99,10 +134,18 @@ jobs:
99134
env:
100135
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
101136

102-
- name: Prevent Workflows from getting Stale
103-
if: always()
104-
uses: gautamkrishnar/keepalive-workflow@v1
137+
- name: Generate a Diagnostic Report
138+
if: failure()
139+
run: |
140+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
141+
142+
- name: Upload the Diagnostic Report
143+
if: failure()
144+
uses: actions/upload-artifact@v4
105145
with:
106-
# this message should prevent automatic triggering of workflows
107-
# see https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
108-
commit_message: "[skip ci] Automated commit by Keepalive Workflow to keep the repository active"
146+
name: diagnose.json.gz
147+
path: ./diagnose.json.gz
148+
149+
- name: Prevent Workflow from becoming Stale
150+
if: always() && github.ref == 'refs/heads/main'
151+
uses: liskin/gh-workflow-keepalive@v1

0 commit comments

Comments
 (0)