mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
49 lines
1.8 KiB
YAML
49 lines
1.8 KiB
YAML
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: '^1.19.0'
|
|
|
|
- name: git config
|
|
run: |
|
|
git config --global http.extraheader "PRIVATE-TOKEN: ${{ secrets.GITHUB_TOKEN }}"
|
|
- name: Create issue using REST API
|
|
run: |
|
|
curl --request POST \
|
|
--url https://api.github.com/repos/${{ github.repository }}/issues \
|
|
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
|
|
--header 'content-type: application/json' \
|
|
--data '{
|
|
"title": "Automated issue for commit: ${{ github.sha }}",
|
|
"body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ github.sha }}_."
|
|
}' \
|
|
--fail
|
|
- name: Vet
|
|
run: |
|
|
make vet
|
|
- name: Unit tests
|
|
run: |
|
|
sudo make test-coverage
|
|
- name: Quality Gate - Test coverage shall be above threshold
|
|
env:
|
|
TESTCOVERAGE_THRESHOLD: 0
|
|
run: |
|
|
echo "Quality Gate: checking test coverage is above threshold ..."
|
|
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
|
|
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
|
|
echo "Current test coverage : $totalCoverage %"
|
|
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
|
|
echo "OK"
|
|
else
|
|
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
|
|
echo "Failed"
|
|
exit 1
|
|
fi
|