-
Notifications
You must be signed in to change notification settings - Fork 10
127 lines (115 loc) · 3.48 KB
/
python-package.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
name: DuckBot CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python Environment
id: venv
uses: ./.github/actions/setup-python-venv
with:
extras: dev
- name: Run Tests
run: |
. ${{ steps.venv.outputs.path }}/bin/activate
pytest --cov=duckbot --cov-branch --cov-report xml --cov-report term-missing:skip-covered
- name: Report Code Coverage
if: ${{ always() }}
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run Linter
run: |
. ${{ steps.venv.outputs.path }}/bin/activate
flake8 duckbot tests
sanity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test Connection to Discord
run: |
docker compose run --rm \
-e 'DUCKBOT_ARGS=connection-test' \
-e "DISCORD_TOKEN=$(cat .github/workflows/test-token.txt | base64 --decode)" \
duckbot
synthesize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up CDK
id: cdk
uses: ./.github/actions/setup-aws-cdk
- name: Synthesize CDK Stack
working-directory: .aws
run: |
. ../${{ steps.cdk.outputs.venv-path }}/bin/activate
cdk synth
release:
needs:
- test
- sanity
- synthesize
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- run: exit 1
if: ${{ contains(needs.*.result, 'failure') }}
- run: echo all checks passed
deploy:
needs:
- release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'duck-dynasty/duckbot'
concurrency: deploy
steps:
- uses: actions/checkout@v4
- name: Build and Push Docker Image
id: image
uses: ./.github/actions/build-push-docker-image
with:
docker-pass: ${{ secrets.DOCKER_PASS }}
- name: Publish Wiki Documentation
uses: SwiftDocOrg/github-wiki-publish-action@v1
with:
path: wiki
env:
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
WIKI_COMMIT_MESSAGE: ${{ github.event.commits[0].message }}
GITHUB_ACTOR: ${{ github.event.commits[0].author.name }}
- name: Set up CDK
id: cdk
uses: ./.github/actions/setup-aws-cdk
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Synthesize CDK Stack
env:
SECRETS: ${{ toJson(secrets) }}
working-directory: .aws
run: |
. ../${{ steps.cdk.outputs.venv-path }}/bin/activate
export $(jq -r 'to_entries | .[] | "\(.key)=\(.value)"' <<< "$SECRETS" | xargs)
echo "::group::cdk synth"
cdk synth --context duckbot_image=${{ steps.image.outputs.commit }}
echo "::endgroup::"
echo "::group::cdk diff"
cdk diff --context duckbot_image=${{ steps.image.outputs.commit }} || true
echo "::endgroup::"
echo "::group::cdk deploy"
cdk deploy \
--force --all \
--context duckbot_image=${{ steps.image.outputs.commit }} \
--context write_secrets=true \
--require-approval never \
--progress events
echo "::endgroup::"