-
Notifications
You must be signed in to change notification settings - Fork 6
165 lines (164 loc) Β· 7.25 KB
/
main.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
name: Iaso Automated CI testing
# This workflow run automatically for every PR on github it checks the syntax and launch the tests.
on:
pull_request:
types: [opened, synchronize, ready_for_review]
push:
# Run On push (or merge) on main. This populates the cache and avoid the issue where we have undetected migrations
# conflict following subsequent merge
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test_js:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Use node.js 20
uses: actions/setup-node@v2
with:
node-version: '20.13.1'
cache: npm
- name: upgrade npm
run: |
npm install --global [email protected]
- name: Environment info
run: |
node --version
npm --version
- name: npm install and test
run: |
npm ci
npm test
- name: Check that no JS translation are missing
run: |
python scripts/update_trads.py
- name: Slack notification
uses: rtCamp/[email protected]
env:
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ':robot_face:'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: iaso-dev
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: ${{ format('Job {0} failed on {1}', github.job, github.ref) }}
SLACK_FOOTER: ${{ format('<https://github.com/{0}/commit/{1}/checks|π{2} logs> | <https://github.com/{0}/commit/{1}/checks|π Commit {1}>', github.repository, github.sha, github.job) }}
MSG_MINIMAL: true
if: failure()
build-and-push-image:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Determining version ${{ github.ref_name }}
id: version
run: |
export GITHUB_BRANCH=${GITHUB_REF##*heads/}
echo $GITHUB_BRANCH
git describe --tags
export VERSION_NAME=$(git describe --tags)--$GITHUB_BRANCH
echo "::set-output name=VERSION_NAME::$VERSION_NAME"
echo "::set-output name=IMAGE_TAG::${{ env.REGISTRY }}/blsq/iaso:$GITHUB_SHA"
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.version.outputs.IMAGE_TAG }}
target: dev
file: docker/bundle/Dockerfile
cache-from: type=registry,ref=ghcr.io/blsq/iaso:buildcache
cache-to: type=registry,ref=ghcr.io/blsq/iaso:buildcache,mode=max
test_python:
runs-on: ubuntu-20.04
services:
postgres:
image: postgis/postgis:12-3.3
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
ports:
- 5432:5432
# needed because the postgres container does not provide a health check
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install GDAL and gettext
run: sudo apt-get update && sudo apt install gdal-bin gettext
- uses: actions/cache@v2
id: cache-venv
with:
path: ./venv/
# The cache key depends on requirements.txt
key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-venv-
# Build a virtualenv, but only if it doesn't already exist
- run: python -v && python -m venv ./venv && . ./venv/bin/activate && pip install -U pip &&
pip install -r requirements-dev.txt
if: steps.cache-venv.outputs.cache-hit != 'true'
- name: Environment info
run: |
pip list
- name: Check formatting with Black
run: |
. ./venv/bin/activate && black --check .
- name: Django tests
run: |
. ./venv/bin/activate && python manage.py compilemessages
. ./venv/bin/activate && python manage.py migrate
. ./venv/bin/activate && python manage.py createcachetable
. ./venv/bin/activate && python -W "ignore" manage.py test
# check we don't have missing migration
. ./venv/bin/activate && python manage.py makemigrations --check
env:
IASO_ENVIRONMENT: development
RDS_DB_NAME: github_actions
SECRET_KEY: secret
DEBUG: true
DJANGO_SETTINGS_MODULE: hat.settings
RDS_PASSWORD: postgres
RDS_HOSTNAME: localhost
RDS_PORT: 5432
RDS_USERNAME: postgres
CACHE: false
DEV_SERVER: true
PLUGINS: polio,wfp
AWS_STORAGE_BUCKET_NAME: iaso-dev
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DEFAULT_FILE_STORAGE: storages.backends.s3boto3.S3Boto3Storage
- name: Slack notification
uses: rtCamp/[email protected]
env:
SLACK_USERNAME: ${{ github.workflow }}
SLACK_ICON_EMOJI: ':robot_face:'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: iaso-dev
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: ${{ format('Job {0} failed on {1}', github.job, github.ref) }}
SLACK_FOOTER: ${{ format('<https://github.com/{0}/commit/{1}/checks|π{2} logs> | <https://github.com/{0}/commit/{1}/checks|π Commit {1}>', github.repository, github.sha, github.job) }}
MSG_MINIMAL: true
if: failure()