-
Notifications
You must be signed in to change notification settings - Fork 15
144 lines (142 loc) · 5.2 KB
/
ci.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
---
# Continous Integration
name: ci
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: 3.9
os_build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
python: [ "3.8", "3.9", "3.10", "3.11"]
node: [ 20 ]
env:
SAM_CLI_TELEMETRY: "0"
AWS_REGION: "us-east-1"
AWS_DEFAULT_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
LOG_PATH: /tmp/debug-logs
PIP_LOG_FILE: /tmp/pip.log
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- uses: actions/checkout@v3
- name: Update Homebrew and save docker version
if: runner.os == 'macOS'
run: |
brew tap homebrew/core
cat "$(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula/d/docker.rb" > .github/brew-formulae
- name: Configure Homebrew docker cache files
uses: actions/cache@v3
if: runner.os == 'macOS'
with:
path: |
~/Library/Caches/Homebrew/docker--*
~/Library/Caches/Homebrew/downloads/*--docker-*
key: brew-${{ hashFiles('.github/brew-formulae') }}
restore-keys: brew-
- name: Install Docker if on MacOS and start colima
id: install_mac_docker
if: runner.os == 'macOS'
run: |
brew install docker --cask
brew install colima
# Docker engine is no longer available because of licensing
# Alternative Colima is part of the github macOS runner
# SAM v1.47.0+ needed for colima support, unable to use Python 3.6
colima start
# Ensure colima is configured for later user
echo "DOCKER_HOST=unix://$HOME/.colima/default/docker.sock" >> $GITHUB_ENV
# Verify Docker
docker ps
docker --version
# Verify colima
colima status
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: 'pip'
- name: Install Dependencies Python
id: install_python
run: |
mkdir "$LOG_PATH"
pip install --upgrade pip
pip install --upgrade setuptools wheel aws-sam-cli -r https://github.com/raw/aws-cloudformation/cloudformation-cli/master/requirements.txt
pip install .
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- name: Install Dependencies Node.js
id: install_nodejs
# Touch needed because of https://github.com/aws/aws-cli/issues/2639
run: |
npm ci --include=optional
find ./node_modules/* -mtime +10950 -exec touch {} \;
npm run build
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: ${{ matrix.os }}-${{ env.pythonLocation }}${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run Unit Tests
id: unit_testing
run: |
pre-commit run --all-files --verbose
- name: Upload Coverage
id: codecov
run: |
curl -s https://codecov.io/bash > codecov.sh
bash codecov.sh -f coverage/py/coverage.xml -F unittests -n codecov-python
bash codecov.sh -f coverage/ts/coverage-final.json -F unittests -n codecov-typescript
- name: Upload Coverage Artifacts
id: upload_coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage/
- name: Run Integration Tests
id: integration_testing
run: |
RPDK_PACKAGE=$(npm pack --silent)
RPDK_PATH=$PWD/$RPDK_PACKAGE
DIR=TestCI
mkdir $DIR
cd "$DIR"
echo "PROJECT_DIR=$PWD" >> $GITHUB_ENV
ls -la
printf "n" | cfn init -vv --artifact-type RESOURCE --type-name AWS::Foo::Bar typescript
ls -la
mkdir ./dist
cp "$RPDK_PATH" ./dist
npm install "./dist/$RPDK_PACKAGE"
cfn generate -vv && cfn validate -vv
npm install --include=optional
sam build --debug --build-dir ./build TypeFunction
sam build --debug --build-dir ./build TestEntrypoint
sam local invoke -t ./build/template.yaml --debug --event ./sam-tests/create.json --log-file ./sam.log TestEntrypoint
grep -q '"SUCCESS"' sam.log
- name: Gather Debug Logs
id: gather_logs
continue-on-error: true
if: failure()
run: |
mkdir "$LOG_PATH/_logs" 2>&1 || :
cp -r "$(npm config get cache)/_logs" "$LOG_PATH" 2>&1 || :
cp "$GITHUB_WORKSPACE/npm-debug.log" "$LOG_PATH/_logs" 2>&1 || :
cp "$PROJECT_DIR/npm-debug.log" "$LOG_PATH/_logs" 2>&1 || :
cp "$PIP_LOG_FILE" "$LOG_PATH" 2>&1 || :
cp "$PROJECT_DIR/rpdk.log" "$LOG_PATH" 2>&1 || :
cp "$PROJECT_DIR/sam.log" "$LOG_PATH" 2>&1 || :
- name: Upload Debug Artifacts
id: upload_logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: debug-logs
path: ${{ env.LOG_PATH }}