-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (136 loc) · 4.28 KB
/
direct.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
on:
workflow_dispatch:
inputs:
pullRequestNumber:
type: string
required: true
default: '0'
externalId:
type: string
required: true
default: '0'
branchToCheckout:
type: string
required: true
default: 'feat/pytest'
jobs:
# oidc_debug_test:
# permissions:
# contents: read
# id-token: write
# runs-on: ubuntu-latest
# name: A test of the oidc debugger
# steps:
# - name: Checkout actions-oidc-debugger
# uses: actions/checkout@v4
# with:
# repository: github/actions-oidc-debugger
# ref: main
# path: ./.github/actions/actions-oidc-debugger
# - name: Debug OIDC Claims
# uses: ./.github/actions/actions-oidc-debugger
# with:
# audience: '${{ github.server_url }}/${{ github.repository_owner }}'
build:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
pullRequestNumber: ${{ inputs.pullRequestNumber }}
externalId: ${{ inputs.externalId }}
permissions:
id-token: write
contents: read
checks: write
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
repository: 'awslabs/generative-ai-cdk-constructs'
- name: Get the PR and test mergeability
if: fromJSON(inputs.pullRequestNumber) > 0
run: |-
gh pr checkout ${{ inputs.pullRequestNumber }};
git merge `gh pr view ${{ inputs.pullRequestNumber }} --json baseRefName | jq -r '.baseRefName'`
echo "::group::Git Differences"
git diff `gh pr view ${{ inputs.pullRequestNumber }} --json baseRefName | jq -r '.baseRefName'`..HEAD
echo "::endgroup::"
- uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
- run: |-
npm install -g aws-cdk
npx projen install
npx projen default
npx projen pre-compile
npx projen compile
npx projen post-compile
npx projen package-all
ls -lR ./dist/
- name: package artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist
samples:
runs-on: ubuntu-latest
needs: build
defaults:
run:
working-directory: samples/python-samples
env:
GH_TOKEN: ${{ github.token }}
pullRequestNumber: ${{ inputs.pullRequestNumber }}
externalId: ${{ inputs.externalId }}
permissions:
id-token: write
contents: read
checks: write
pull-requests: read
steps:
- uses: actions/checkout@v4
with:
repository: 'aws-samples/generative-ai-cdk-constructs-samples'
ref: "${{ inputs.branchToCheckout }}"
- name: Download package
uses: actions/download-artifact@v4
with:
name: dist
path: samples/python-samples/dist
- run: |-
ls -l;
cat requirements.txt | sed -e 's/^cdklabs\.generative-ai-cdk-constructs.*$/file\:\.\/dist\/python\/cdklabs\.generative_ai_cdk_constructs-0\.0\.0-py3-none-any\.whl/g' > requirements-local.txt
cat requirements-local.txt;
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: |
'samples/python-samples/requirements.txt'
'samples/python-samples/requirements-local.txt'
'samples/python-samples/requirements-dev.txt'
- run: |-
pip freeze
python -m venv .venv
source .venv/bin/activate
pip freeze
pip install -r requirements-local.txt
pip install -r requirements-dev.txt
pip freeze
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: |-
npm install -g aws-cdk
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 7200
mask-aws-account-id: true
- run: 'cdk synthesize'
- run: 'cdk diff'
- run: 'cdk deploy --all --require-approval never'
- run: pytest