From d5fd4ac3d4e44973c6643feea73be11557cf95cf Mon Sep 17 00:00:00 2001 From: Raphael Simon Date: Wed, 27 Sep 2023 20:37:18 -0700 Subject: [PATCH] Make DeepSource action work for all PRs Use a workflow_run action so that it can access the secret required to upload to Deep Source. --- .deepsource.toml | 2 +- .github/workflows/build.yml | 26 +++++++++++++++++++++++ .github/workflows/ci.yml | 35 ------------------------------- .github/workflows/deep-source.yml | 22 +++++++++++++++++++ Makefile | 4 ++-- 5 files changed, 51 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deep-source.yml diff --git a/.deepsource.toml b/.deepsource.toml index 6ea534161e..01fcf74f22 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -6,4 +6,4 @@ enabled = true name = "go" [analyzers.meta] - import_root = "github.com/goadesign/goa" \ No newline at end of file + import_root = "goa.design/goa/v3" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..523b19a82b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: build +on: [push, pull_request] +jobs: + ci: + strategy: + fail-fast: true + matrix: + go: ['1.20', '1.21'] + os: ['ubuntu-latest', 'windows-latest'] + runs-on: ${{ matrix.os }} + steps: + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + id: go + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + - name: Build + run: make ci + - name: Upload test coverage for deep source + uses: actions/upload-artifact@v3 + with: + name: coverage + path: cover.out + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 8b975b012d..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: build -on: [push, pull_request] -jobs: - ci: - strategy: - fail-fast: true - matrix: - go: ['1.20', '1.21'] - os: ['ubuntu-latest', 'windows-latest'] - runs-on: ${{ matrix.os }} - steps: - - name: Set up Go ${{ matrix.go }} - uses: actions/setup-go@v4 - with: - go-version: ${{ matrix.go }} - id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - - name: Extract branch name - run: echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: Add $GOPATH/bin to PATH - run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - id: setup_path - - name: Build - run: make ci - env: - GOA_BRANCH: ${{ steps.extract_branch.outputs.branch }} - - name: Report test-coverage to DeepSource - if: github.event_name == 'push' && matrix.os == 'ubuntu-latest' - run: | - curl https://deepsource.io/cli | sh - ./bin/deepsource report --analyzer test-coverage --key go --value-file ./cover.out - env: - DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} diff --git a/.github/workflows/deep-source.yml b/.github/workflows/deep-source.yml new file mode 100644 index 0000000000..d158d99471 --- /dev/null +++ b/.github/workflows/deep-source.yml @@ -0,0 +1,22 @@ +name: deepsource +on: + workflow_run: + workflows: [build] + types: [completed] + +jobs: + on-success: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' + steps: + - name: Download test coverage + uses: actions/download-artifact@v3 + with: + name: coverage + path: cover.out + - name: Report analysis to DeepSource + run: | + curl https://deepsource.io/cli | sh + ./bin/deepsource report --analyzer test-coverage --key go --value-file ./cover.out + env: + DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }} \ No newline at end of file diff --git a/Makefile b/Makefile index 88eb2d169d..6d8ab8bdd4 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ test: go test ./... --coverprofile=cover.out release: release-goa release-examples release-plugins + @echo "Release v$(MAJOR).$(MINOR).$(BUILD) complete" release-goa: # First make sure all is clean @@ -85,7 +86,7 @@ release-goa: git checkout v$(MAJOR) && \ git pull origin v$(MAJOR) && \ git diff-index --quiet HEAD - go mod tidy -compat=1.17 + go mod tidy # Bump version number, commit and push sed 's/Major = .*/Major = $(MAJOR)/' pkg/version.go > _tmp && mv _tmp pkg/version.go sed 's/Minor = .*/Minor = $(MINOR)/' pkg/version.go > _tmp && mv _tmp pkg/version.go @@ -118,5 +119,4 @@ release-plugins: git tag v$(MAJOR).$(MINOR).$(BUILD) && \ git push origin v$(MAJOR) && \ git push origin v$(MAJOR).$(MINOR).$(BUILD) - echo DONE RELEASING v$(MAJOR).$(MINOR).$(BUILD)!