Wait For validation #519
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: Build | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
golangci-lint: | |
name: golangci-lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3 | |
with: | |
# Hard-coding version due to this bug: https://github.com/golangci/golangci-lint-action/issues/535 | |
version: v1.52.2 | |
test: | |
name: go test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 | |
with: | |
go-version: 1.18 | |
- name: Set up gotestfmt | |
uses: GoTestTools/gotestfmt-action@v2 | |
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: go-test-${{ hashFiles('**/go.sum') }} | |
restore-keys: go-test- | |
- name: Run go test | |
run: | | |
set -euo pipefail | |
go generate | |
go test -coverprofile /tmp/coverage.out -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | |
echo "# Code coverage summary" > /tmp/coverage.md | |
echo "|File|Type|Coverage|" >> /tmp/coverage.md | |
echo "|----|----|--------|" >> /tmp/coverage.md | |
go tool cover -func /tmp/coverage.out | sed -e 's/\s\s*/|/g' -e 's/^/|/g' -e 's/$/|/g' >> /tmp/coverage.md | |
cat /tmp/coverage.md >> $GITHUB_STEP_SUMMARY | |
echo "::group::Code coverage summary" | |
go tool cover -func /tmp/coverage.out | |
echo "::endgroup::" | |
- name: Upload test log | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3 | |
if: always() | |
with: | |
name: test-results | |
path: | | |
/tmp/gotest.log | |
/tmp/coverage.out | |
/tmp/coverage.md | |
if-no-files-found: error | |
generate: | |
name: go generate | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 | |
with: | |
go-version: 1.18 | |
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: go-test-${{ hashFiles('**/go.sum') }} | |
restore-keys: go-generate- | |
- name: Run go generate | |
run: ./.github/scripts/gogenerate.sh | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: | |
- golangci-lint | |
- test | |
- generate | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4 | |
with: | |
go-version: 1.18 | |
- name: Login to Quay.io | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3 | |
if: startsWith(github.event.ref, 'refs/tags/') | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Build and release | |
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5 | |
if: startsWith(github.event.ref, 'refs/tags/') | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GOPROXY: direct | |
GOSUMDB: off | |
- name: Build | |
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5 | |
if: ${{ !startsWith(github.event.ref, 'refs/tags/') }} | |
with: | |
distribution: goreleaser | |
version: latest | |
args: build --snapshot | |
env: | |
GOPROXY: direct | |
GOSUMDB: off | |
- name: Upload artifacts | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3 | |
with: | |
name: binaries | |
path: dist | |
build_python_wheel: | |
name: build python wheel | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
steps: | |
- name: version format check | |
if: startsWith(github.event.ref, 'refs/tags/') | |
shell: bash | |
env: | |
VERSION: ${{ github.ref_name }} | |
run: | | |
[[ ${VERSION//[[:blank:]]/} =~ ^v[[:digit:]]+\.[[:digit:]]\.[[:digit:]](-[[:alnum:]]+)?(\+[[:alnum:]]+)?$ ]] && export OK="[INF] version format accepted" | |
[[ -z $OK ]] && echo "[ERR] wrong version format: $VERSION" && exit 1 | |
echo $OK | |
- name: Check out code | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3 | |
with: | |
name: binaries | |
path: python/artifacts | |
- name: Install Python | |
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4 | |
with: | |
python-version: '3.9' | |
architecture: 'x64' | |
- name: Grab the License file | |
run: | | |
cp LICENSE python/ | |
- name: Fetch python dependencies | |
working-directory: python | |
shell: bash | |
run: | | |
make setup | |
- name: Bump version | |
working-directory: python | |
if: startsWith(github.event.ref, 'refs/tags/') | |
env: | |
VERSION: ${{ github.ref_name }} | |
shell: bash | |
run: | | |
sed -ri "s/^(.+version=')(.+)('.*)/\1${VERSION/v/}\3/g" setup.py | |
- name: Build python wheel | |
working-directory: python | |
run: | | |
make all | |
- name: Push to pypi | |
working-directory: python | |
if: startsWith(github.event.ref, 'refs/tags/') | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}} | |
run: | | |
twine upload dist/* | |