Merge pull request #369 from sdcio/FixDeleteBranch #646
This file contains hidden or 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: CI/CD Test per PR | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| pull_request_target: | |
| types: [labeled] | |
| push: | |
| branches: | |
| - "main" | |
| - "!releases/**" | |
| permissions: | |
| packages: write | |
| jobs: | |
| unittest: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| - run: go test -cover -coverprofile=coverage.txt ./... | |
| env: | |
| CGO_ENABLED: 0 | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| pr-release: | |
| if: contains(github.event.pull_request.labels.*.name, 'safe to test') | |
| runs-on: ubuntu-latest | |
| needs: unittest | |
| outputs: | |
| dataversion: ${{ steps.image.outputs.version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{github.event.pull_request.head.ref}} | |
| repository: ${{github.event.pull_request.head.repo.full_name}} | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Run GoReleaser | |
| id: goreleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| # either 'goreleaser' (default) or 'goreleaser-pro' | |
| distribution: goreleaser | |
| version: latest | |
| args: release --clean -f .goreleaser.nightlies.yml --skip=validate | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR: ${{ github.event.pull_request.number }} | |
| - name: Extract docker image build version from GoReleaser | |
| id: image | |
| run: | | |
| echo "version=$( echo '${{ steps.goreleaser.outputs.artifacts }}' | jq '.[] | select(.type == "Published Docker Image" and (.name | contains("ghcr.io")) and (.name | contains("latest") | not)) | .name | split(":") | .[1]' )" >> $GITHUB_OUTPUT | |
| latest-versions: | |
| name: Fetch latest versions from GH API | |
| runs-on: ubuntu-latest | |
| outputs: | |
| schemaversion: ${{ steps.latest-versions.outputs.schemaversion }} | |
| dataversion: ${{ steps.latest-versions.outputs.dataversion }} | |
| cacheversion: ${{ steps.latest-versions.outputs.cacheversion }} | |
| configversion: ${{ steps.latest-versions.outputs.configversion }} | |
| certmanagerversion: ${{ steps.latest-versions.outputs.certmanagerversion }} | |
| steps: | |
| - name: Set env vars | |
| id: latest-versions | |
| run: | | |
| echo "schemaversion=$( curl -sL https://api.github.com/repos/sdcio/schema-server/releases/latest | jq '.name' )" >> $GITHUB_OUTPUT | |
| echo "dataversion=$( curl -sL https://api.github.com/repos/sdcio/data-server/releases/latest | jq '.name' )" >> $GITHUB_OUTPUT | |
| echo "cacheversion=$( curl -sL https://api.github.com/repos/sdcio/cache/releases/latest | jq '.name' )" >> $GITHUB_OUTPUT | |
| echo "configversion=$( curl -sL https://api.github.com/repos/sdcio/config-server/releases/latest | jq '.name' )" >> $GITHUB_OUTPUT | |
| echo "certmanagerversion=$( curl -sL https://api.github.com/repos/cert-manager/cert-manager/releases/latest | jq '.name' )" >> $GITHUB_OUTPUT | |
| integration-tests: | |
| needs: [latest-versions, pr-release] | |
| uses: sdcio/integration-tests/.github/workflows/single.yml@main | |
| with: | |
| configserver_version: ${{ needs.latest-versions.outputs.configversion }} | |
| dataserver_version: ${{ needs.pr-release.outputs.dataversion }} | |
| schemaserver_version: ${{ needs.latest-versions.outputs.schemaversion }} | |
| cache_version: ${{ needs.latest-versions.outputs.cacheversion }} | |
| certmanager_version: ${{ needs.latest-versions.outputs.certmanagerversion }} | |
| secrets: inherit |