Skip to content

Commit

Permalink
Make DeepSource action work for all PRs
Browse files Browse the repository at this point in the history
Use a workflow_run action so that it can access the secret required to
upload to Deep Source.
  • Loading branch information
raphael committed Sep 28, 2023
1 parent 4df75cd commit d5fd4ac
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ enabled = true
name = "go"

[analyzers.meta]
import_root = "github.com/goadesign/goa"
import_root = "goa.design/goa/v3"
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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

35 changes: 0 additions & 35 deletions .github/workflows/ci.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/deep-source.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)!

0 comments on commit d5fd4ac

Please sign in to comment.