Merge pull request #113 from linted/bugfix/imports #204
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 Yahoo Inc. | |
# Licensed under the terms of the Apache License 2.0. Please see LICENSE file in project root for terms. | |
name: CI-Tests | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: read-all | |
jobs: | |
unit-tests: | |
name: Run ${{matrix.go}} unit tests | |
permissions: | |
contents: read | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest ] | |
go: [ '1.18.x', '1.19.x' ] | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | |
with: | |
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | |
- name: checkout | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | |
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds | |
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 | |
with: | |
# In order: | |
# * Module download cache | |
# * Build cache (Linux) | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Setup go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version: ${{ matrix.go }} | |
- name: Install required packages | |
run: sudo apt-get install -y libpam0g-dev | |
- name: Run Go vet | |
run: go vet -v ./... | |
- name: Run Go build | |
run: go build ./cmd/... | |
- name: Run Go tests | |
run: go test -covermode atomic -coverprofile coverage.txt ./... | |
- name: Upload Coverage Report | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 | |
with: | |
file: ./coverage.txt | |
- name: Run Go tests with `-race` | |
run: go test -v -race ./... | |