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: add separate CI worflows to run library tests and linting #224

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 19 additions & 0 deletions .github/workflows/ci-rebac-admin-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ci-rebac-admin-backend
run-name: CI (rebac-admin) for ${{ github.sha }} on ${{ github.ref_name }}

on:
workflow_dispatch:
push:
branches:
- "feature-rebac-admin-ui-backend"
pull_request:
branches:
- "*"

jobs:
lint:
name: Perform linting
uses: ./.github/workflows/rebac-admin-backend-lint.yaml
unit-test:
name: Run unit tests
uses: ./.github/workflows/rebac-admin-backend-unittest.yaml
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 28 additions & 0 deletions .github/workflows/rebac-admin-backend-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
run-name: Unit test steps for ${{ github.sha }} on ${{ github.ref_name }}

on:
workflow_call:

permissions:
contents: read
pull-requests: read
checks: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
name: Checkout repo

- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
name: Setup Go version
with:
go-version: '1.21'
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved

- uses: golangci/golangci-lint-action@v3
name: Perform linting and annotate code
with:
version: latest
working-directory: ./rebac-admin-backend
only-new-issues: true
29 changes: 29 additions & 0 deletions .github/workflows/rebac-admin-backend-unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
run-name: Unit test steps for ${{ github.sha }} on ${{ github.ref_name }}

on:
workflow_call:

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: '1.21'
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved

- name: Build and test Go code
working-directory: ./rebac-admin-backend
run: make test


- uses: codecov/codecov-action@c4cf8a4f03f0ac8585acb7c1b7ce3460ec15782f # v4
with:
files: ./rebac-admin-backend/coverage.out

- name: Upload Go test results
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: Go-results
path: ./rebac-admin-backend/test.json
6 changes: 5 additions & 1 deletion rebac-admin-backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ mocks:

# Run tests
test: mocks
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved
go test ./...
go test ./... -cover -coverprofile coverage_source.out
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved
# this will be cached, just needed to the test.json
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved
go test ./... -cover -coverprofile coverage_source.out -json > test_source.json
cat coverage_source.out | grep -v "mock_*" | tee coverage.out
cat test_source.json | grep -v "mock_*" | tee test.json
BarcoMasile marked this conversation as resolved.
Show resolved Hide resolved
.PHONY: test
Loading