-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (150 loc) · 4.92 KB
/
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
name: Backend & Frontend Test
on:
push:
# This should disable running the workflow on tags, according to the
# on.<push|pull_request>.<branches|tags> GitHub Actions docs.
# cheers @ https://github.com/psycopg/psycopg/blob/5681de9c42f916d5b2436ad9c6f47b79c8aeaa12/.github/workflows/tests.yml#L4-L8
branches:
- "*"
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * *"
workflow_call:
workflow_dispatch: # manual
jobs:
secret-scan:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.
build-docker:
uses: dbadrian/zest/.github/workflows/build-docker.yaml@main
test-backend:
runs-on: ubuntu-latest
needs: [build-docker]
env:
DJANGO_SETTINGS_MODULE: zest.settings.dev
DJANGO_SECRET_KEY: "JASIDJ*@ioda89dY2hdaiophd80a23p06i%8-4ods3"
DJANGO_ALLOWED_HOSTS: localhost,0.0.0.0,127.0.0.1
DJANGO_AUTH_MODE: jwt
TESTFLAGS: "--with-coverage --cover-xml --cover-erase"
SQL_ENGINE: django.db.backends.postgresql
SQL_DATABASE: zest
SQL_USER: zest
SQL_PASSWORD: zest
SQL_HOST: db
SQL_PORT: 5432
UID: 1001
GID: 121
REDIS_ADDRESS: redis://cache:6379/1
steps:
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- name: "📂 download docker artifacts"
uses: actions/download-artifact@v4
with:
name: docker
path: /tmp
- name: "📦 load tag"
run: |
docker load --input /tmp/docker.tar
docker image ls -a
# - name: Initialize backend
# run: |
# task backend-init-ci
- name: Test
run: task backend-test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: backend/coverage.xml
flags: backend
token: ${{ secrets.CODECOV_TOKEN }}
test-frontend:
runs-on: ubuntu-latest
needs: [build-docker]
env:
DJANGO_SETTINGS_MODULE: zest.settings.dev
DJANGO_SECRET_KEY: "JASIDJ*@ioda89dY2hdaiophd80a23p06i%8-4ods3"
DJANGO_ALLOWED_HOSTS: localhost,0.0.0.0,127.0.0.1
DJANGO_AUTH_MODE: jwt
TESTFLAGS: "--with-coverage --cover-xml --cover-erase"
SQL_ENGINE: django.db.backends.postgresql
SQL_DATABASE: zest
SQL_USER: zest
SQL_PASSWORD: zest
SQL_HOST: db
SQL_PORT: 5432
UID: 1001
GID: 121
REDIS_ADDRESS: redis://cache:6379/1
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
# Setup the flutter environment.
- uses: subosito/flutter-action@v2
with:
channel: "stable" # 'dev', 'alpha', default to: 'stable'
# flutter-version: '1.12.x' # you can also specify exact version of flutter
- run: flutter --version
- run: flutter --disable-analytics
- name: Install Ubuntu Dependencies
run: sudo apt-get install -y lcov sqlite3 libsqlite3-dev libsecret-1-0 libsecret-1-dev
- name: Prepare environment.
run: flutter pub get
- name: Check formatting
run: dart format --set-exit-if-changed .
- name: Build runner
run: dart run build_runner build --delete-conflicting-outputs
- name: Static code analysis (no-fatal-infos)
run: flutter analyze . --no-fatal-infos --no-fatal-warnings
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📂 download docker artifacts"
uses: actions/download-artifact@v4
with:
name: docker
path: /tmp
- name: "📦 load tag"
run: |
docker load --input /tmp/docker.tar
docker image ls -a
- name: Initialize backend
run: |
task backend-init-ci
# - name: Start docker
# run: |
# task docker-start &
- name: Tests
run: |
task docker-start
flutter test --coverage
- name: Generate Coverage
run: |
lcov --ignore-errors unused --remove coverage/lcov.info 'lib/*/*.freezed.dart' 'lib/*.g.dart' 'lib/*/*.part.dart' 'lib/generated/*.dart' 'lib/generated/*/*.dart' -o coverage/lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage/lcov.info
flags: frontend
token: ${{ secrets.CODECOV_TOKEN }}