Skip to content

feat(tricks): prime numbers functions #126

feat(tricks): prime numbers functions

feat(tricks): prime numbers functions #126

Workflow file for this run

name: tests
on:
pull_request:
push:
branches:
- master
env:
GH_ACCESS_TOKEN: ${{ secrets.GLOBAL_REPO_TOKEN || github.token }}
BADGE_GIST_ID: 69229998008a13b9b87590ebe50ecded
jobs:
test:
strategy:
matrix:
go-version:
- "1.21"
module:
- bricks
- tricks
- kareless
- handywares
runs-on: ubuntu-latest
name: Run tests of ${{ matrix.module }} using go v${{ matrix.go-version }}
env:
covfile: coverage_${{ matrix.module }}.out
steps:
- name: Make filename-friendly ref
run: |
REF=${{ github.ref }}
echo "REF=$(echo ${REF//\//_})" >> $GITHUB_ENV
- name: Install go v${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Grant private repositories access
id: grant-repo-access
run: git config --global url."https://${{ env.GH_ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"
- name: Create go workspace
run: |
[ -f go.work ] || go work init
go work use ${{ matrix.module }}
go version
- name: Run tests for ${{ matrix.module }}
uses: n8maninger/action-golang-test@v1
with:
args: "-test.short;-count=1;-race;-covermode=atomic;-coverprofile=${{ env.covfile }}"
package: ./${{ matrix.module }}/...
show-stdout: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: short
env_vars: REF
- name: Expose code coverage manually
run: |
go tool cover -func=${{ env.covfile }} -o=${{ env.covfile }}
COVERAGE="$(cat ${{ env.covfile }} | tail -1 | awk '{print $NF}')"
echo "COVERAGE=$(echo ${COVERAGE%\%})" >> $GITHUB_ENV
- name: Create coverage badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.BADGE_GIST_TOKEN }}
gistID: ${{ env.BADGE_GIST_ID }}
filename: ${{ github.repository_owner }}_${{ github.event.repository.name }}_${{ matrix.module }}_${{ env.REF }}.json
namedLogo: codecov
logoColor: "#F01F7A"
label: Test Coverage
message: ${{ env.COVERAGE }}%
valColorRange: ${{ env.COVERAGE }}
maxColorRange: 95
minColorRange: 70