Feature/testing #53
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
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. | |
test-backend: | |
runs-on: ubuntu-latest | |
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: postgres | |
SQL_PASSWORD: postgres | |
SQL_HOST: db | |
SQL_PORT: 5432 | |
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: Build docker images | |
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 | |
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: postgres | |
SQL_PASSWORD: postgres | |
SQL_HOST: db | |
SQL_PORT: 5432 | |
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: 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: Build docker images | |
run: | | |
task backend-init-ci | |
task docker-start | |
- name: Tests | |
run: flutter test --coverage | |
- name: Generate Coverage | |
run: | | |
sudo apt-get install -y lcov | |
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 }} |