diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..a7ff632d --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,56 @@ +name: Build +on: + push: + branches: + - main + tags: + - v* + pull_request: +jobs: + lint_and_test: + name: lint and test + uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_lint_and_test.yaml@main + with: + go_version: ${{ vars.ARCALOT_GO_VERSION }} + 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: ${{ vars.ARCALOT_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 + permissions: + contents: write + needs: + - lint_and_test + - generate + uses: arcalot/arcaflow-reusable-workflows/.github/workflows/go_release.yaml@main + secrets: + QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + with: + go_version: ${{ vars.ARCALOT_GO_VERSION }} + for_release: ${{ startsWith(github.event.ref, 'refs/tags/') }} + build_python_wheel: + name: build python wheel + needs: + - release + uses: arcalot/arcaflow-reusable-workflows/.github/workflows/python_release.yaml@main + secrets: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + with: + python_version: ${{ vars.ARCALOT_PYTHON_VERSION }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 685a31b6..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,194 +0,0 @@ -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/* - -