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

Setup pipeline jobs to run code tests & linters in gha/ci #19

Merged
merged 1 commit into from
Apr 4, 2024
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
3 changes: 3 additions & 0 deletions .changelog/19.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
golang: Setup checks related to golang in gha/ci
```
90 changes: 90 additions & 0 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Go

on:
push:
branches:
- main
pull_request:

# permissions:
# # Required: allow read access to the content for analysis.
# contents: read
# # Optional: allow read access to pull request. Use with `only-new-issues` option.
# # pull-requests: read
# # Optional: Allow write access to checks to allow the action to annotate code in the PR.
# checks: write

jobs:
linters:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '^1.22' ]
name: Go ${{ matrix.go }} linters
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go }}
check-latest: false
cache: false
id: go
- name: golangci-lint
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: v1.57
# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# skip-cache: true
tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '^1.22' ]
name: Go ${{ matrix.go }} tests
# needs: [linters]
env:
CA_CERT: ${{ secrets.CA_CERT }}
CA_KEY: ${{ secrets.CA_KEY }}
INVALID_CERT: ${{ secrets.INVALID_CERT }}
INVALID_CERT_KEY: ${{ secrets.INVALID_CERT_KEY }}
SERVER_CERT: ${{ secrets.SERVER_CERT }}
SERVER_CERT_KEY: ${{ secrets.SERVER_CERT_KEY }}
SERVER_REQ_PEM: ${{ secrets.SERVER_REQ_PEM }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ matrix.go }}
check-latest: false
cache: false
id: go
- name: Get dependencies
run: go get -v -t -d ./...
- name: generate certs for tests
run: |
mkdir -p testdata
echo "$CA_CERT" > testdata/ca-cert.pem
echo "$CA_KEY" > testdata/ca-key.pem
echo "$INVALID_CERT" > testdata/invalid-cert.pem
echo "$INVALID_CERT_KEY" > testdata/invalid-cert.key
echo "$SERVER_CERT" > testdata/server-cert.pem
echo "$SERVER_CERT_KEY" > testdata/server-key.key
echo "$SERVER_REQ_PEM" > testdata/server-req.pem
- name: Test
run: go test -v -coverprofile=coverage.out ./...
Loading