Skip to content

Commit

Permalink
Add lint and test Github Actions
Browse files Browse the repository at this point in the history
 - Since we don't yet have SDLC pipeline projects for Go libraries or
   for public projects, add in some limited CI validation for PRs to
   this repo including:

   * A build and test stage that generates binaries with the Makefile
     *and* runs make test-coverage to produce coverage (not currently
     used in CI)

     Also uploads these as artifacts

   * Linting through the golangci-lint Github Action

 - NOTE: intially use dorny/test-reporter which produces Github checks,
   which by design doesn't always attach to the right workflow - results
   may show up with golangci-lint. See

   dorny/test-reporter#67
   https://github.com/orgs/community/discussions/24616

   To resolve this, switch to a fork that uses summary instead:
   phoenix-actions/test-reporting#21
  • Loading branch information
ddl-ebrown committed May 26, 2024
1 parent c2f8c49 commit ae72b03
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: golangci-lint

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
41 changes: 41 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: test

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@main
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install dependencies
run: make common-deps
- name: Run tests
run: make test-coverage
- name: Archive test and code coverage results
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
test/*.xml
**/cover.out
- name: Produce Summary Report
if: always() # run this step even if previous step failed
uses: phoenix-actions/test-reporting@v15
with:
name: report
path: test/*.xml
reporter: java-junit
output-to: 'step-summary'

0 comments on commit ae72b03

Please sign in to comment.