security(docker): bump golang from 620e0c8
to 21edeab
#395
Workflow file for this run
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: Code Metrics | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
coverage: | |
runs-on: ubuntu-latest | |
name: Update coverage | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Setup go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run Test | |
id: test | |
run: | | |
make clean cover | |
VAL=$(tail -1 coveragef.out | sed -E "s/[^0-9]*([0-9]+\.[0-9]*)%/\1/") | |
OLD_VAL=$(curl "https://gist.githubusercontent.com/michad/d1b9e082f6608635494188d0f52bae69/raw/coverage.json" | jq '.message | rtrimstr("%") | tonumber') | |
MSG="Code coverage" | |
if [ $(bc <<< "$VAL == $OLD_VAL") -eq 1 ]; then | |
MSG="$MSG is unchanged at $VAL%" | |
elif [ $(bc <<< "$VAL < $OLD_VAL") -eq 1 ]; then | |
MSG="$MSG decreased from $OLD_VAL% to $VAL%" | |
else | |
MSG="$MSG increased from $OLD_VAL% to $VAL%" | |
fi | |
echo "VAL=$VAL" >> $GITHUB_OUTPUT | |
echo "MSG=$MSG" >> $GITHUB_OUTPUT | |
- name: Comment on PR | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: github.event_name == 'pull_request' | |
env: | |
MSG: ${{ steps.test.outputs.MSG }} | |
with: | |
script: | | |
let comments = (await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
})).data; | |
let id = null; | |
for(let i in comments) { | |
if(comments[i].user?.login == 'github-actions[bot]' && comments[i].body.startsWith("Code coverage ")){ | |
id=comments[i].id; | |
break; | |
} | |
} | |
if(id !== null){ | |
github.rest.issues.updateComment({ | |
comment_id: id, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.MSG | |
}); | |
console.log("update comment " + id); | |
} else{ | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.MSG | |
}); | |
} | |
- name: Create the Badge | |
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0 | |
if: github.event_name != 'pull_request' | |
env: | |
VAL: ${{ steps.test.outputs.VAL }} | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: d1b9e082f6608635494188d0f52bae69 | |
filename: coverage.json | |
label: Coverage | |
message: ${{ env.VAL }}% | |
valColorRange: ${{ env.VAL }} | |
maxColorRange: 90 | |
minColorRange: 50 | |
libyears: | |
runs-on: ubuntu-latest | |
name: Update libyears | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Setup go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run Test | |
id: test | |
run: | | |
VAL=$(make libyears | /usr/bin/jq '.libyear | .*100 | round/100') | |
OLD_VAL=$(curl "https://gist.githubusercontent.com/michad/d1b9e082f6608635494188d0f52bae69/raw/libyears.json" | jq '.message | rtrimstr(" years") | tonumber') | |
MSG="Libyears" | |
if [ $(bc <<< "$VAL == $OLD_VAL") -eq 1 ]; then | |
MSG="$MSG is unchanged at $VAL" | |
elif [ $(bc <<< "$VAL < $OLD_VAL") -eq 1 ]; then | |
MSG="$MSG decreased from $OLD_VAL to $VAL" | |
else | |
MSG="$MSG increased from $OLD_VAL to $VAL" | |
fi | |
echo "VAL=$VAL" >> $GITHUB_OUTPUT | |
echo "MSG=$MSG" >> $GITHUB_OUTPUT | |
- name: Comment on PR | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: github.event_name == 'pull_request' | |
env: | |
MSG: ${{ steps.test.outputs.MSG }} | |
with: | |
script: | | |
let comments = (await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
})).data; | |
let id = null; | |
for(let i in comments) { | |
if(comments[i].user?.login == 'github-actions[bot]' && comments[i].body.startsWith("Libyears ")){ | |
id=comments[i].id; | |
break; | |
} | |
} | |
if(id !== null){ | |
github.rest.issues.updateComment({ | |
comment_id: id, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.MSG | |
}); | |
} else{ | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: process.env.MSG | |
}) | |
} | |
- name: Create the Badge | |
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0 | |
if: github.event_name != 'pull_request' | |
env: | |
VAL: ${{ steps.test.outputs.VAL }} | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: d1b9e082f6608635494188d0f52bae69 | |
filename: libyears.json | |
label: Libyears | |
message: ${{ env.VAL }} years | |
invertColorRange: true | |
valColorRange: ${{ env.VAL }} | |
maxColorRange: 50 | |
minColorRange: 0 |