Skip to content

Commit 90f792a

Browse files
committed
fix: reimplementing workflows
1 parent ee6748b commit 90f792a

File tree

16 files changed

+265
-131
lines changed

16 files changed

+265
-131
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 'Generate Deployment JSON'
2+
description: 'Generate deployment.json from example template'
3+
inputs:
4+
account_id:
5+
description: 'AWS account ID'
6+
required: true
7+
build_from_source:
8+
description: 'Whether to build from source'
9+
required: false
10+
default: 'true'
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Generate deployment.json
15+
working-directory: cdk
16+
shell: bash
17+
env:
18+
ACCOUNT_ID: ${{ inputs.account_id }}
19+
BUILD_FROM_SOURCE: ${{ inputs.build_from_source }}
20+
run: |
21+
python3 << 'EOF'
22+
import json
23+
import os
24+
with open('bin/deployment/deployment.json.example') as f:
25+
config = json.load(f)
26+
config['account']['id'] = os.environ['ACCOUNT_ID']
27+
config['account']['prodLike'] = False
28+
build_from_source = os.environ.get('BUILD_FROM_SOURCE', 'true').lower() == 'true'
29+
if 'networkConfig' in config:
30+
del config['networkConfig']
31+
if 'dataplaneConfig' in config:
32+
config['dataplaneConfig']['BUILD_FROM_SOURCE'] = build_from_source
33+
if 'testModelsConfig' in config:
34+
config['testModelsConfig']['BUILD_FROM_SOURCE'] = build_from_source
35+
with open('bin/deployment/deployment.json', 'w') as f:
36+
json.dump(config, f, indent=2)
37+
EOF
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Setup AWS OIDC'
2+
description: 'Configure AWS credentials using OIDC'
3+
inputs:
4+
aws_region:
5+
description: 'AWS region'
6+
required: true
7+
account_id:
8+
description: 'AWS account ID'
9+
required: true
10+
role_duration_seconds:
11+
description: 'Role session duration in seconds'
12+
required: false
13+
default: '7200'
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Configure AWS Credentials
18+
uses: aws-actions/configure-aws-credentials@v4
19+
with:
20+
aws-region: ${{ inputs.aws_region }}
21+
role-to-assume: arn:aws:iam::${{ inputs.account_id }}:role/GithubAction-AssumeRoleWithAction
22+
role-session-name: GitHub_to_AWS_via_FederatedOIDC
23+
role-duration-seconds: ${{ inputs.role_duration_seconds }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Setup CDK'
2+
description: 'Setup Node.js and install CDK dependencies'
3+
inputs:
4+
node_version:
5+
description: 'Node.js version'
6+
required: false
7+
default: '24'
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Setup Node.js
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: ${{ inputs.node_version }}
15+
cache: 'npm'
16+
cache-dependency-path: cdk/package-lock.json
17+
- name: Install CDK and dependencies
18+
working-directory: cdk
19+
shell: bash
20+
run: |
21+
npm install -g aws-cdk
22+
npm ci
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Setup Python'
2+
description: 'Setup Python with caching'
3+
inputs:
4+
python_version:
5+
description: 'Python version'
6+
required: false
7+
default: '3.13'
8+
cache_dependency_paths:
9+
description: 'Glob pattern for dependency files for caching (e.g., **/requirements*.txt or pyproject.toml)'
10+
required: false
11+
default: '**/requirements*.txt'
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Setup Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ inputs.python_version }}
19+
cache: 'pip'
20+
cache-dependency-path: ${{ inputs.cache_dependency_paths }}
21+
- name: Upgrade pip
22+
shell: bash
23+
run: python -m pip install --upgrade pip

.github/workflows/build-test-destroy.yml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,40 @@ permissions:
1616
contents: read
1717
actions: read
1818

19+
concurrency:
20+
group: validate-${{ github.ref }}
21+
cancel-in-progress: false
22+
1923
jobs:
20-
'Deploy / CheckPendingWorkflow':
24+
check:
2125
uses: ./.github/workflows/check-pending-workflow.yml
2226
secrets: inherit
2327

24-
'Deploy / DeployModelRunner':
25-
needs: 'Deploy / CheckPendingWorkflow'
28+
deploy:
29+
needs: check
2630
uses: ./.github/workflows/deploy.yml
2731
with:
2832
aws_region: ${{ env.AWS_REGION }}
29-
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
3033
build_from_source: true
31-
secrets: inherit
34+
secrets:
35+
MODEL_RUNNER_ACCOUNT_ID: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
3236

33-
'Test / RunIntegrationTests':
34-
needs: 'Deploy / DeployModelRunner'
37+
test:
38+
needs: deploy
3539
uses: ./.github/workflows/run-integration-tests.yml
3640
with:
3741
aws_region: ${{ env.AWS_REGION }}
38-
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
39-
secrets: inherit
42+
secrets:
43+
MODEL_RUNNER_ACCOUNT_ID: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
4044

41-
'Cleanup / DestroyModelRunner':
42-
if: ${{ always() }}
45+
destroy:
46+
if: always()
4347
needs:
44-
- 'Deploy / CheckPendingWorkflow'
45-
- 'Deploy / DeployModelRunner'
46-
- 'Test / RunIntegrationTests'
48+
- check
49+
- deploy
50+
- test
4751
uses: ./.github/workflows/destroy.yml
4852
with:
4953
aws_region: ${{ env.AWS_REGION }}
50-
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
51-
secrets: inherit
54+
secrets:
55+
MODEL_RUNNER_ACCOUNT_ID: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ on:
77
permissions:
88
contents: read
99

10+
concurrency:
11+
group: build-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
11-
tox:
15+
test:
1216
uses: ./.github/workflows/tox.yml
1317
secrets: inherit
1418
docker:

.github/workflows/check-pending-workflow.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
name: Check Pending Workflow
1+
name: Check Pending Workflows
22

33
permissions:
44
contents: read
55
actions: read
66

77
on:
88
workflow_call:
9-
secrets:
10-
GITHUB_TOKEN:
11-
required: false
129

1310
jobs:
14-
check:
11+
check-pending-workflows:
1512
runs-on: ubuntu-latest
13+
timeout-minutes: 125 # Slightly more than timeout (7200000ms = 120 minutes)
1614
steps:
1715
- name: Check for pending workflows
1816
uses: ahmadnassri/action-workflow-queue@v1

.github/workflows/deploy.yml

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy
1+
name: Deploy Infrastructure
22

33
permissions:
44
id-token: write
@@ -10,60 +10,44 @@ on:
1010
aws_region:
1111
required: true
1212
type: string
13-
account_id:
14-
required: true
15-
type: string
1613
build_from_source:
1714
required: false
1815
type: boolean
1916
default: true
17+
secrets:
18+
MODEL_RUNNER_ACCOUNT_ID:
19+
required: true
2020

2121
env:
2222
AWS_REGION: ${{ inputs.aws_region }}
2323
AWS_PAGER: ""
24+
NODE_VERSION: '24'
25+
PYTHON_VERSION: '3.13'
2426

2527
jobs:
26-
deploy:
28+
deploy-infrastructure:
2729
runs-on: ubuntu-latest
30+
timeout-minutes: 60
2831
steps:
2932
- name: Checkout code
3033
uses: actions/checkout@v4
3134
with:
3235
lfs: 'true'
33-
- name: Configure AWS Credentials
34-
uses: aws-actions/configure-aws-credentials@v4
36+
- name: Setup AWS OIDC
37+
uses: ./.github/actions/setup-aws-oidc
3538
with:
36-
aws-region: ${{ inputs.aws_region }}
37-
role-to-assume: arn:aws:iam::${{ inputs.account_id }}:role/GithubAction-AssumeRoleWithAction
38-
role-session-name: GitHub_to_AWS_via_FederatedOIDC
39-
role-duration-seconds: 7200
40-
- name: Setup Node.js
41-
uses: actions/setup-node@v4
39+
aws_region: ${{ inputs.aws_region }}
40+
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
41+
role_duration_seconds: '7200'
42+
- name: Setup CDK
43+
uses: ./.github/actions/setup-cdk
4244
with:
43-
node-version: '18'
44-
- name: Install CDK and dependencies
45-
working-directory: cdk
46-
run: |
47-
npm install -g aws-cdk
48-
npm install
45+
node_version: ${{ env.NODE_VERSION }}
4946
- name: Generate deployment.json
50-
working-directory: cdk
51-
run: |
52-
python3 << 'EOF'
53-
import json
54-
with open('bin/deployment/deployment.json.example') as f:
55-
config = json.load(f)
56-
config['account']['id'] = '${{ inputs.account_id }}'
57-
config['account']['prodLike'] = False
58-
if 'networkConfig' in config:
59-
del config['networkConfig']
60-
if 'dataplaneConfig' in config:
61-
config['dataplaneConfig']['BUILD_FROM_SOURCE'] = ${{ inputs.build_from_source }}
62-
if 'testModelsConfig' in config:
63-
config['testModelsConfig']['BUILD_FROM_SOURCE'] = ${{ inputs.build_from_source }}
64-
with open('bin/deployment/deployment.json', 'w') as f:
65-
json.dump(config, f, indent=2)
66-
EOF
47+
uses: ./.github/actions/generate-deployment-json
48+
with:
49+
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
50+
build_from_source: ${{ inputs.build_from_source }}
6751
- name: Build and synthesize CDK
6852
working-directory: cdk
6953
run: |

.github/workflows/destroy.yml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Destroy
1+
name: Destroy Infrastructure
22

33
permissions:
44
id-token: write
@@ -10,50 +10,38 @@ on:
1010
aws_region:
1111
required: true
1212
type: string
13-
account_id:
13+
secrets:
14+
MODEL_RUNNER_ACCOUNT_ID:
1415
required: true
15-
type: string
1616

1717
env:
1818
AWS_REGION: ${{ inputs.aws_region }}
1919
AWS_PAGER: ""
20+
NODE_VERSION: '24'
21+
PYTHON_VERSION: '3.13'
2022

2123
jobs:
22-
destroy:
24+
destroy-infrastructure:
2325
runs-on: ubuntu-latest
26+
timeout-minutes: 45
2427
steps:
2528
- name: Checkout code
2629
uses: actions/checkout@v4
27-
- name: Configure AWS Credentials
28-
uses: aws-actions/configure-aws-credentials@v4
30+
- name: Setup AWS OIDC
31+
uses: ./.github/actions/setup-aws-oidc
2932
with:
30-
aws-region: ${{ inputs.aws_region }}
31-
role-to-assume: arn:aws:iam::${{ inputs.account_id }}:role/GithubAction-AssumeRoleWithAction
32-
role-session-name: GitHub_to_AWS_via_FederatedOIDC
33-
role-duration-seconds: 14400
34-
- name: Setup Node.js
35-
uses: actions/setup-node@v4
33+
aws_region: ${{ inputs.aws_region }}
34+
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
35+
role_duration_seconds: '14400'
36+
- name: Setup CDK
37+
uses: ./.github/actions/setup-cdk
3638
with:
37-
node-version: '18'
38-
- name: Install CDK and dependencies
39-
working-directory: cdk
40-
run: |
41-
npm install -g aws-cdk
42-
npm install
39+
node_version: ${{ env.NODE_VERSION }}
4340
- name: Generate deployment.json
44-
working-directory: cdk
45-
run: |
46-
python3 << 'EOF'
47-
import json
48-
with open('bin/deployment/deployment.json.example') as f:
49-
config = json.load(f)
50-
config['account']['id'] = '${{ inputs.account_id }}'
51-
config['account']['prodLike'] = False
52-
if 'networkConfig' in config:
53-
del config['networkConfig']
54-
with open('bin/deployment/deployment.json', 'w') as f:
55-
json.dump(config, f, indent=2)
56-
EOF
41+
uses: ./.github/actions/generate-deployment-json
42+
with:
43+
account_id: ${{ secrets.MODEL_RUNNER_ACCOUNT_ID }}
44+
build_from_source: 'false'
5745
- name: Build CDK
5846
working-directory: cdk
5947
run: npm run build

.github/workflows/docker.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Build & Publish
1+
name: Build Docker Image
22

33
on:
44
workflow_call:
@@ -13,9 +13,14 @@ env:
1313
REGISTRY: awsosml
1414
IMAGE_NAME: ${{ github.event.repository.name }}
1515

16+
concurrency:
17+
group: docker-build-${{ github.ref }}
18+
cancel-in-progress: true
19+
1620
jobs:
17-
docker:
21+
build-docker-image:
1822
runs-on: ubuntu-latest
23+
timeout-minutes: 45
1924
steps:
2025
- uses: actions/checkout@v4
2126
with:
@@ -36,10 +41,14 @@ jobs:
3641
type=semver,pattern={{raw}},enable=${{ github.event_name == 'release' }}
3742
type=raw,value=nightly-dev,enable=${{ github.ref == 'refs/heads/main' && github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
3843
type=raw,value={{date 'YYYYMMDD-hhmmss' tz='UTC'}},enable=${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
3946
- uses: docker/build-push-action@v5
4047
with:
4148
context: .
4249
file: ./docker/Dockerfile.model-runner
4350
push: ${{ env.push }}
4451
tags: ${{ steps.meta.outputs.tags }}
4552
labels: ${{ steps.meta.outputs.labels }}
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)