Skip to content

Commit

Permalink
Merge pull request #125 from pwei1018/feature-ci-upgrade
Browse files Browse the repository at this point in the history
Test CI coverage flow.
  • Loading branch information
pwei1018 authored Apr 25, 2024
2 parents 967edfe + c2a6c13 commit 3f0933b
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 9 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/notify-api-ci.codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Notify Codecov CI

on:
workflow_run:
workflows: ["Notify API CI"]
types:
- completed

jobs:
codecov:
name: unit-testing
defaults:
run:
shell: bash
working-directory: ./notify-api

strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest" ]

runs-on: ${{ matrix.os }}

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Download artifacts
uses: dawidd6/action-download-artifact@v3
with:
name: backend-coverage-${{ github.sha }}
run_id: ${{ github.event.workflow_run.id }}
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
file: coverage.xml
flags: notifapi
name: codecov-notifyapi
url: https://codecov-dev.apps.gold.devops.gov.bc.ca
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
114 changes: 107 additions & 7 deletions .github/workflows/notify-api-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Notify API CI

on:
pull_request:
push:
paths:
- "notify-api/**"
workflow_dispatch:
Expand All @@ -12,9 +12,109 @@ defaults:
working-directory: ./notify-api

jobs:
notify-api-ci:
uses: bcgov/bcregistry-sre/.github/workflows/backend-ci.yaml@main
with:
app_name: "notify-api"
working_directory: "./notify-api"
codecov_flag: "notifyapi"
linting:
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest" ]

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash
working-directory: ./notify-api

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v4
- name: Install Poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ./notify-api/pyproject.toml
cache: poetry
cache-dependency-path: ./notify-api/poetry.lock
- name: Install dependencies
run: poetry install
#----------------------------------------------
# install and run linters
#----------------------------------------------
- name: Run isort
run: |
poetry run isort . --check
- name: Run black
run: |
poetry run black . --check
- name: Run pylint
run: |
poetry run pylint .
- name: Run flake8
run: |
poetry run flake8 .
unit-testing:
needs: linting

defaults:
run:
shell: bash
working-directory: ./notify-api

strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest" ]

env:
DATABASE_TEST_USERNAME: "postgres"
DATABASE_TEST_PASSWORD: "postgres"
DATABASE_TEST_NAME: "postgres"
DATABASE_TEST_HOST: "localhost"
DATABASE_TEST_PORT: "5432"

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

runs-on: ${{ matrix.os }}
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v4
- name: Install Poetry
run: |
pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ./notify-api/pyproject.toml
cache: poetry
cache-dependency-path: ./notify-api/poetry.lock
- name: Install dependencies
run: poetry install
#----------------------------------------------
# add matrix specifics and run test suite
#----------------------------------------------
- name: Run tests
run: |
poetry run pytest
- uses: actions/upload-artifact@v4
with:
name: backend-coverage-${{ github.sha }}
path: ./notify-api/coverage.xml
2 changes: 1 addition & 1 deletion gcp/iam/application-roles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#!/bin/bash

declare -a environments=("dev" "test" "tools" "prod" "integration" "sandbox")
declare -a projects=("a083gt" "mvnjri" "gtksf3" "yfjq17" "c4hnrd" "k973yf" "yfthig" "eogruh")
declare -a projects=("a083gt" "mvnjri" "gtksf3" "yfjq17" "c4hnrd" "k973yf" "yfthig" "eogruh" "bcrbk9")
declare -a services=("api" "job" "queue" "cdcloudrun")

for ev in "${environments[@]}"
Expand Down
2 changes: 1 addition & 1 deletion gcp/iam/cd-cloudrun-role.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

declare -a environments=("dev" "test" "tools" "prod" "integration" "sandbox")
#declare -a projects=("a083gt" "mvnjri" "gtksf3" "yfjq17" "c4hnrd" "k973yf" "yfthig" "eogruh" "bcrbk9")
declare -a projects=("a083gt" "eogruh" "bcrbk9")
declare -a projects=("bcrbk9")
declare -a service="cdcloudrun"

for ev in "${environments[@]}"
Expand Down

0 comments on commit 3f0933b

Please sign in to comment.