Split tests into separate workflow

Split tests into separate development workflow that can be included within ci file.

Restrict ci to only run on pushes to main/beta branches.

run dev workflow on pull requests
This commit is contained in:
Jean Fernandez 2024-03-03 22:17:54 -05:00
parent a386e43772
commit 159743baee
3 changed files with 76 additions and 53 deletions

View File

@ -1,66 +1,22 @@
name: CI name: CI
# This workflow is triggered on pushes & pull requests # This workflow is triggered on pushes
on: on:
pull_request:
branches:
- main
- sandbox
- beta
push: push:
branches: [ main, beta ] branches: [ main, beta ]
# Publish semver tags as releases. # Publish semver tags as releases.
release: release:
types: [published] types: [published]
jobs: jobs:
test-frontend: test:
name: Test Frontend uses: ./.github/workflows/development.yaml
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: test
uses: actions/setup-node@v1
with:
node-version: 20.x
- name: Test Frontend
run: |
make test-frontend-coverage
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: ${{ github.workspace }}/frontend/coverage/fastenhealth/lcov.info
retention-days: 1
test-backend:
name: Test Backend
runs-on: ubuntu-latest
container: ghcr.io/packagrio/packagr:latest-golang
env:
STATIC: true
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Test Backend
run: |
go install github.com/golang/mock/mockgen@v1.6.0
go generate ./...
make test-backend-coverage
CGO_ENABLED=0 go build -buildvcs=false ./backend/cmd/fasten/
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: ${{ github.workspace }}/backend-coverage.txt
retention-days: 1
test-coverage: test-coverage:
name: Test Coverage Upload name: Test Coverage Upload
needs: needs:
- test-backend - test
- test-frontend
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Download coverage reports - name: Download coverage reports
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@ -72,12 +28,11 @@ jobs:
flags: unittests flags: unittests
fail_ci_if_error: true fail_ci_if_error: true
verbose: true verbose: true
storybook: storybook:
name: Storybook Upload name: Storybook Upload
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- run: cd frontend && yarn install - run: cd frontend && yarn install

68
.github/workflows/development.yaml vendored Normal file
View File

@ -0,0 +1,68 @@
name: Development
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
workflow_call:
jobs:
test-frontend:
name: Test Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Test Frontend
run: |
make test-frontend-coverage
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: ${{ github.workspace }}/frontend/coverage/fastenhealth/lcov.info
retention-days: 1
test-backend:
name: Test Backend
runs-on: ubuntu-latest
container: ghcr.io/packagrio/packagr:latest-golang
env:
STATIC: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup
run: |
go install github.com/golang/mock/mockgen@v1.6.0
go generate ./...
- name: Test Backend
run: |
make test-backend-coverage
CGO_ENABLED=0 go build -buildvcs=false ./backend/cmd/fasten/
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: ${{ github.workspace }}/backend-coverage.txt
retention-days: 1
compile-storybook:
name: Compile Storybook
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup
uses: actions/setup-node@v4
with:
node-version: 20.x
- run: |
make build-storybook

View File

@ -9,11 +9,11 @@ test: test-backend test-frontend
.PHONY: build-storybook .PHONY: build-storybook
build-storybook: dep-frontend build-storybook: dep-frontend
cd frontend && ng run fastenhealth:build-storybook cd frontend && npx ng run fastenhealth:build-storybook
.PHONY: serve-storybook .PHONY: serve-storybook
serve-storybook: dep-frontend serve-storybook: dep-frontend
cd frontend && ng run fastenhealth:storybook cd frontend && npx ng run fastenhealth:storybook
.PHONY: serve-frontend .PHONY: serve-frontend
serve-frontend: dep-frontend serve-frontend: dep-frontend