Backend & Frontend Test #220
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: | |
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/cache@v2 | |
with: | |
path: ${{ runner.tool_cache }}/flutter | |
key: flutter-3.27.0-stable | |
- uses: ./ | |
with: | |
channel: stable | |
flutter-version: 3.27.0 | |
# Setup the flutter environment. | |
# todo infer and sync flutter version in the future | |
- uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
flutter-version: '3.27.0' | |
- 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 }} |