Namespaced scopes #821
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: | |
env: | |
go_version: 1.21.6 | |
jobs: | |
golangci-lint: | |
name: golangci-lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: v1.55.2 | |
test: | |
name: go test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Set up gotestfmt | |
uses: GoTestTools/gotestfmt-action@v2 | |
- uses: actions/cache@v4 | |
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@v4 | |
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@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.go_version }} | |
- uses: actions/cache@v4 | |
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@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.go_version }} | |
- name: Login to Quay.io | |
uses: docker/login-action@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@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@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@v4 | |
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@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: binaries | |
path: python/artifacts | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
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/* | |