forked from alphagov/notifications-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (116 loc) · 4.02 KB
/
pr.yaml
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
name: PR Validation
on:
pull_request:
branches: ["main"]
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Don't want the tests running in parallel
cancel-in-progress: true
jobs:
app-build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
node-version: ["20.10.0"]
steps:
- uses: szenius/set-timezone@v2.0
with:
timezoneLinux: "Europe/Amsterdam"
name: Set Timezone to Europe/Amsterdam
- uses: actions/checkout@v4
name: Checkout repository
- uses: gerlero/apt-install@v1
with:
packages: build-essential git libcurl4-openssl-dev curl libssl-dev
install-recommends: false
name: Install OS dependencies (apt)
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
name: Install Python [${{ matrix.python-version }}] and setup cache
- uses: BSFishy/pip-action@v1
with:
requirements: requirements_for_test.txt
name: Install application requirements (pip)
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache-dependency-path: package-lock.json
name: Install NodeJS [${{ matrix.node-version }}] and setup cache
- run: npm ci
name: Install application requirements (npm)
- uses: astral-sh/ruff-action@v2
name: Linting (ruff)
- uses: jpetrucciani/black-check@master
name: Formatting (black)
- uses: BSFishy/pip-action@v1
with:
packages: |
pytest-md
pytest-emoji
name: Install test dependencies
# TODO: fix automated tests
# Connection from runner to test database is needed for tests to run
# or somehow sending a custom job to k8s that would run the tests and report back
- uses: pavelzw/pytest-action@v2
with:
verbose: false
job-summary: true
continue-on-error: true
name: Run tests (pytest)
- run: npm test
name: Run tests (node)
docker-build-and-push:
runs-on: ubuntu-latest
needs: app-build-and-test
steps:
- uses: actions/checkout@v4
- run: |
TAG=$(date +%Y%m%d).${{ github.run_number }}.dev
echo "TAG=$TAG" >> $GITHUB_ENV
echo "tag=$TAG" >> $GITHUB_OUTPUT
name: Set tag
id: set-tag
- run: |
echo -e "__git_commit__ = \"${{ github.sha }}\"\n__time__ = \"$(date)\"\n__version__ = \"${{ env.TAG }}\"" > ./app/version.py
name: Generate version.py before building image
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
name: Login at dockerhub
- uses: docker/setup-qemu-action@v3
name: Setup QEMU
- uses: docker/setup-buildx-action@v3
name: Setup buildx
- uses: docker/build-push-action@v6
with:
file: docker/Dockerfile
push: true
tags: worthnl/notifynl-admin:${{ env.TAG }}
name: Docker build and push ${{ env.TAG }}
outputs:
tag: ${{ steps.set-tag.outputs.tag }}
helm-release:
runs-on: ubuntu-latest
needs: docker-build-and-push
environment: Test
steps:
- uses: actions/checkout@v4
with:
repository: Worth-NL/notifynl-charts-private
ref: main
token: ${{ secrets.WORTHNL_PAT }}
name: Checkout Worth-NL/notifynl-charts-private
- uses: bwvolleyball/k8s-toolkit@v1.0.0
with:
config: ${{ secrets.K8S_CONFIG }}
- run: |
helm version
helm upgrade --install notifynl-admin notifynl-admin/ -n ${{ secrets.K8S_NAMESPACE }} --reuse-values --set dockerTagOverride=${{ needs.docker-build-and-push.outputs.tag }} --wait
name: Deploy chart