-
-
Notifications
You must be signed in to change notification settings - Fork 1
181 lines (159 loc) · 5.09 KB
/
pr-test.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
---
name: Test
concurrency: test
on:
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
changes:
runs-on: ubuntu-latest
outputs:
src: ${{ steps.changes.outputs.src }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- src/**
- test/**
- Cargo.toml
- Cargo.lock
test:
needs: changes
if: needs.changes.outputs.src == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
rust-toolchain:
- stable
- nightly
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Update local toolchain
run: |
rustup update
- name: Install nightly
if: matrix.rust-toolchain == 'nightly'
run: |
rustup install nightly
rustup default ${{ matrix.rust-toolchain }}
- name: Install clippy
if: matrix.rust-toolchain == 'stable'
run: |
rustup component add clippy
- name: Toolchain info
run: |
cargo --version --verbose
rustc --version
[ "${{ matrix.rust-toolchain }}" == 'stable' ] && cargo clippy --version || :
- name: Dependency cache
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-${{ matrix.rust-toolchain }}-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.rust-toolchain }}-target-
- name: Lint
if: matrix.rust-toolchain == 'stable'
run: |
cargo fmt -- --check
cargo clippy -- -D warnings
- name: Test
run: |
cargo check
cargo test --all
- name: Build
run: |
cargo install --path .
- uses: actions/setup-node@v3
if: matrix.rust-toolchain == 'stable'
with:
node-version: 16
- name: npm dependency cache
if: matrix.rust-toolchain == 'stable'
uses: actions/cache@v3
with:
path: test/cdk/.npm
key: ${{ runner.os }}-${{ matrix.rust-toolchain }}-node-${{ hashFiles('test/cdk/node_modules/package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ matrix.rust-toolchain }}-node-
- name: Prepare test stacks
if: matrix.rust-toolchain == 'stable'
env:
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
make test
- name: Run test migrations
if: matrix.rust-toolchain == 'stable'
working-directory: test/cdk
run: |
echo "######### Testing migration from ${STACK1} to ${STACK2} #########"
cfn-teleport --source "${STACK1}" --target "${STACK2}" --yes \
--resource "${BUCKET1}" \
--resource "${BUCKET2}" \
--resource "${INSTANCE}" \
--resource "${SECURITY_GROUP}" \
--resource "${KEY_PAIR}" \
--resource "${INSTANCE_PROFILE}" \
--resource "${ROLE}" \
--resource "${DYNAMO_TABLE}"
if npx cdk diff --fail; then
echo "Migration failed, cdk diff did not show changes"
exit 1
fi
echo "######### Testing migration from ${STACK2} to ${STACK1} #########"
cfn-teleport --source "${STACK2}" --target "${STACK1}" --yes \
--resource "${BUCKET1}" \
--resource "${BUCKET2}" \
--resource "${INSTANCE}" \
--resource "${SECURITY_GROUP}" \
--resource "${KEY_PAIR}" \
--resource "${INSTANCE_PROFILE}" \
--resource "${ROLE}" \
--resource "${DYNAMO_TABLE}"
if ! npx cdk diff --fail; then
echo "Migration failed, cdk diff did show changes"
exit 1
fi
env:
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
STACK1: CfnTeleportTest1
STACK2: CfnTeleportTest2
BUCKET1: Bucket182C536A1
BUCKET2: Bucket21D68F7E8
INSTANCE: InstanceC1063A87
SECURITY_GROUP: SecurityGroupDD263621
KEY_PAIR: KeyPair
INSTANCE_PROFILE: InstanceInstanceProfileAB5AEF02
ROLE: Role1ABCC5F0
DYNAMO_TABLE: DynamoDbTable6316879D
- name: Delete test stacks
if: matrix.rust-toolchain == 'stable'
run: |
make test-reset
env:
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
report-status:
name: success
if: ${{ ! failure() }}
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Report success
run: echo 'Success'