Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade CI/CD to match Goa #556

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version = 1
[[analyzers]]
name = "test-coverage"
enabled = true
[[analyzers]]
name = "go"
[analyzers.meta]
import_root = "goa.design/model"
[[analyzers]]
name = "secrets"
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
53 changes: 0 additions & 53 deletions .github/workflows/main.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/report-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Report Test Coverage

on:
workflow_run:
workflows:
- Run Static Checks and Tests
types: [completed]

jobs:
report:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'

steps:
- name: Check out code
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_branch }}

- name: Download test coverage
uses: dawidd6/action-download-artifact@v2
with:
workflow: test.yml
name: coverage

- 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 }}
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run Static Checks and Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
strategy:
fail-fast: true
matrix:
go: ['1.20', '1.21']
os: ['ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
id: go

- name: Build
run: make ci

- name: Upload test coverage for deep source
if: matrix.go == '1.21' && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: coverage
path: cover.out
22 changes: 10 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DEPEND=\
github.com/golangci/golangci-lint/cmd/golangci-lint@latest \
github.com/mjibson/esc@latest

all: lint check-generated test
all: lint test build

ci: depend all

Expand All @@ -46,15 +46,17 @@ ifneq ($(GOOS),windows)
fi
endif

check-generated: generate
@if ! git diff -s --exit-code cmd/mdl/webapp.go; then \
echo 'cmd/mdl/webapp.go is different, run `make generate` before commit!'; \
fi

test:
go test ./...
go test ./... --coverprofile=cover.out

build:
@cd cmd/mdl && go install
@cd cmd/stz && go install

release:
serve: build
@cmd/mdl/mdl serve

release: build
# First make sure all is clean
@git diff-index --quiet HEAD
@go mod tidy
Expand All @@ -67,10 +69,6 @@ release:
@sed 's/model@v.*\/\(.*\)tab=doc/model@v$(MAJOR).$(MINOR).$(BUILD)\/\1tab=doc/' README.md > _tmp && mv _tmp README.md
@sed 's/model@v.*\/\(.*\)tab=doc/model@v$(MAJOR).$(MINOR).$(BUILD)\/\1tab=doc/' DSL.md > _tmp && mv _tmp DSL.md

# Make sure mdl and stz build
@cd cmd/mdl && go install
@cd cmd/stz && go install

# Commit and push
@git add .
@git commit -m "Release v$(MAJOR).$(MINOR).$(BUILD)"
Expand Down