i'm not going to remove it 🤫 #134
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
name: Go | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.19.1 | |
- name: Get coverage tool | |
run: | | |
cd application/backend | |
go get golang.org/x/tools/cmd/cover | |
REF=${{ github.ref }} | |
IFS='/' read -ra PATHS <<< "$REF" | |
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}" | |
echo $BRANCH_NAME | |
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV | |
- name: Create failing badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 7a0933f8cba0bddbcc95c8b850e32663 | |
filename: onlogs_passing__${{ env.BRANCH }}.json | |
label: Tests | |
message: Failed | |
color: red | |
namedLogo: checkmarx | |
- name: Test | |
run: | | |
cd application/backend | |
go test ./... -coverprofile cover.out | |
go tool cover -func cover.out > covered.txt | |
- name: Get coverage | |
run: | | |
cd application/backend | |
for word in $(cat covered.txt); do total_percent=$word; done | |
echo $total_percent | |
echo "COVERAGE=$total_percent" >> $GITHUB_ENV | |
- name: Create passing badge | |
uses: schneegans/[email protected] | |
if: ${{ env.COVERAGE!=null }} | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 7a0933f8cba0bddbcc95c8b850e32663 | |
filename: onlogs_passing__${{ env.BRANCH }}.json | |
label: Tests | |
message: Passed | |
color: green | |
namedLogo: checkmarx | |
- name: Create coverage badge | |
uses: schneegans/[email protected] | |
if: ${{ env.COVERAGE!=null }} | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: 7a0933f8cba0bddbcc95c8b850e32663 | |
filename: onlogs_units_coverage__${{ env.BRANCH }}.json | |
label: Test Coverage | |
message: ${{ env.COVERAGE }} | |
color: green | |
namedLogo: go |