Skip to content

Fixes GitHub actions vulnerability #327

Fixes GitHub actions vulnerability

Fixes GitHub actions vulnerability #327

name: checks
on:
pull_request:
branches:
- master
- stable/**
push:
branches:
- master
- stable/**
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: linters
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.46.2
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
unit:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{matrix.os}}
name: unit tests ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
- uses: actions/checkout@v3
- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run the tests
run: |
go test -v ./... -covermode=count -coverprofile=${{ runner.os }}-coverage.out
- if: runner.os != 'Windows'
name: Prepare the artifact
run: |
go tool cover -html=${{ runner.os }}-coverage.out -o ${{ runner.os }}-coverage.html
- name: Get run details
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo "PR_Title=$PR_TITLE"
echo "Run_Number=${{ github.run_number }}"
echo "PR_Number=${{ github.event.pull_request.number }}"
- if: runner.os != 'Windows'
name: Upload the artifact
uses: actions/upload-artifact@v2
with:
name: "coverage-report-${{ runner.os }}-${{ github.run_number }}.html"
path: ${{ runner.os }}-coverage.html