Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split out backends and migrations into own repo #9

Merged
merged 13 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 90 additions & 2 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
language: [go, java, javascript, python]
language: [go, java, python]
include:
- language: go
working-directory: backend-go
Expand All @@ -31,7 +31,6 @@ jobs:
- language: "java"
working-directory: backend-java
build: ./mvnw package -DskipTests
- language: "javascript"
- language: "python"
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -89,3 +88,92 @@ jobs:
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"

java:
name: Java
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
defaults:
run:
working-directory: backend-java
services:
postgres:
image: postgres
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Run unit tests
run: mvn -f pom.xml clean package

python:
name: Python
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
defaults:
run:
working-directory: backend-py
services:
postgres:
image: postgres
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: cache poetry install
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ hashFiles('**/pyproject.toml') }}

- uses: snok/install-poetry@v1.3.4
with:
version: 1.2.2
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- id: cache-deps
uses: actions/cache@v3
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

- run: poetry run pytest
123 changes: 58 additions & 65 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@ jobs:
deploys-test:
name: TEST Deploys
environment: test
runs-on: ubuntu-22.04
permissions:
issues: write
runs-on: ubuntu-22.04
strategy:
matrix:
name:
- init
- database
- backend
- backend-go
- backend-java
- backend-py
- frontend
package: [init, database, backend-go, backend-java, backend-py, frontend]
include:
- name: init
file: common/openshift.init.yml
overwrite: false
repository: bcgov/quickstart-openshift
- name: database
file: database/openshift.deploy.yml
overwrite: false
- name: backend
file: backend/openshift.deploy.yml
parameters: -p PROMOTE_MIGRATION=${{ github.repository }}/database-migrations:test
overwrite: true
verification_path: /api
repository: bcgov/quickstart-openshift
triggers: ('backend-go' 'backend-java' 'backend-py')
- name: backend-go
file: backend-go/openshift.deploy.yml
overwrite: true
parameters: -p PROMOTE_MIGRATION=${{ github.repository }}/database-migrations-go:test
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
-p PROMOTE_MIGRATION=${{ github.repository }}/migrations-go:test
triggers: ('backend-go/')
- name: backend-java
file: backend-java/openshift.deploy.yml
overwrite: true
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
triggers: ('backend-java/')
- name: backend-py
file: backend-py/openshift.deploy.yml
overwrite: true
parameters: -p PROMOTE_MIGRATION=${{ github.repository }}/database-migrations-py:test
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
-p PROMOTE_MIGRATION=${{ github.repository }}/migrations-py:test
triggers: ('backend-py/')
- name: frontend
file: frontend/openshift.deploy.yml
overwrite: true
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
repository: bcgov/quickstart-openshift
triggers: ('database/' 'backend/' 'frontend/')
steps:
- uses: bcgov-nr/action-deployer-openshift@v1.4.0
with:
Expand All @@ -61,13 +61,13 @@ jobs:
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: ${{ matrix.overwrite }}
penetration_test: false
parameters:
-p ZONE=test -p PROMOTE=${{ github.repository }}/${{ matrix.name }}:test
-p NAME=${{ github.event.repository.name }} ${{ matrix.parameters }}
penetration_test: true
penetration_test_artifact: ${{ matrix.name }}
penetration_test_issue: ${{ matrix.name }}
penetration_test_token: ${{ secrets.GITHUB_TOKEN }}
-p ZONE=test -p NAME=${{ github.event.repository.name }}
-p PROMOTE=${{ github.repository }}/${{ matrix.name }}:test
${{ matrix.parameters }}
repository: ${{ matrix.repository }}
triggers: ${{ matrix.triggers }}
verification_path: ${{ matrix.verification_path }}

integration-tests:
Expand All @@ -79,12 +79,10 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
name: [quarkus, nest, fiber, fastapi]
name: [quarkus, fiber, fastapi]
include:
- name: quarkus
baseUrl: https://quickstart-openshift-test-backend-java.apps.silver.devops.gov.bc.ca
- name: nest
baseUrl: https://quickstart-openshift-test-backend.apps.silver.devops.gov.bc.ca
- name: fiber
baseUrl: https://quickstart-openshift-test-backend-go.apps.silver.devops.gov.bc.ca
- name: fastapi
Expand Down Expand Up @@ -161,16 +159,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
name:
- frontend
- backend
- backend-go
- backend-py
- backend-java
- database
- database-migrations
- database-migrations-go
- database-migrations-py
name: [backend-go, backend-py, backend-java, migrations-go, migrations-py]
steps:
- name: Keep last 50
uses: actions/delete-package-versions@v4
Expand All @@ -182,46 +171,47 @@ jobs:

deploys-prod:
name: PROD Deploys
needs: [integration-tests, cypress-e2e]
environment: prod
needs: [integration-tests, cypress-e2e]
permissions:
issues: write
runs-on: ubuntu-22.04
strategy:
matrix:
name:
- backend
- database
- frontend
- init
- backend-py
- backend-java
- backend-go
package: [init, database, backend-go, backend-java, backend-py, frontend]
include:
- name: backend
file: backend/openshift.deploy.yml
parameters: -p PROMOTE_MIGRATION=${{ github.repository }}/database-migrations:test
overwrite: true
verification_path: /api
- name: database
file: database/openshift.deploy.yml
overwrite: false
- name: frontend
file: frontend/openshift.deploy.yml
overwrite: true
- name: init
file: common/openshift.init.yml
overwrite: false
- name: backend-py
file: backend-py/openshift.deploy.yml
repository: bcgov/quickstart-openshift
- name: database
file: database/openshift.deploy.yml
overwrite: false
repository: bcgov/quickstart-openshift
triggers: ('backend-go' 'backend-java' 'backend-py')
- name: backend-go
file: backend-go/openshift.deploy.yml
overwrite: true
parameters: -p PROMOTE_MIGRATION=${{ github.repository }}/database-migrations-py:test
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
-p PROMOTE_MIGRATION=${{ github.repository }}/migrations-go:prod
triggers: ('backend-go/')
- name: backend-java
file: backend-java/openshift.deploy.yml
overwrite: true
- name: backend-go
file: backend-go/openshift.deploy.yml
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
triggers: ('backend-java/')
- name: backend-py
file: backend-py/openshift.deploy.yml
overwrite: true
parameters: -p PROMOTE_MIGRATION=${{ github.repository }}/database-migrations-go:test

parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
-p PROMOTE_MIGRATION=${{ github.repository }}/migrations-py:prod
triggers: ('backend-py/')
- name: frontend
file: frontend/openshift.deploy.yml
overwrite: true
parameters: -p MIN_REPLICAS=1 -p MAX_REPLICAS=2
repository: bcgov/quickstart-openshift
triggers: ('database/' 'backend/' 'frontend/')
steps:
- uses: bcgov-nr/action-deployer-openshift@v1.4.0
with:
Expand All @@ -230,10 +220,13 @@ jobs:
oc_server: ${{ vars.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
overwrite: ${{ matrix.overwrite }}
parameters:
-p ZONE=prod -p PROMOTE=${{ github.repository }}/${{ matrix.name }}:test
-p NAME=${{ github.event.repository.name }} ${{ matrix.parameters }}
penetration_test: false
parameters:
-p ZONE=prod -p NAME=${{ github.event.repository.name }}
-p PROMOTE=${{ github.repository }}/${{ matrix.name }}:prod
${{ matrix.parameters }}
repository: ${{ matrix.repository }}
triggers: ${{ matrix.triggers }}
verification_path: ${{ matrix.verification_path }}

image-promotions:
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,7 @@ jobs:
packages: write
strategy:
matrix:
package:
- backend
- database
- database-migrations
- frontend
- database-migrations-py
- backend-py
- backend-java
- backend-go
- database-migrations-go
package: [backend-go, backend-java, backend-py, migrations-go, migrations-py]
steps:
- uses: shrink/actions-docker-registry-tag@v3
with:
Expand Down
Loading
Loading