Skip to content

Commit

Permalink
Unify Go CI. (#890)
Browse files Browse the repository at this point in the history
* Unify CI.

* whitespace
  • Loading branch information
adlerjohn authored Jul 6, 2022
1 parent d8d80fb commit 3f2d743
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 74 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,43 @@ on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
GO_VERSION: 1.18
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io

jobs:
docker-build:
runs-on: "ubuntu-latest"
permissions:
contents: write
packages: write
contents: write
packages: write

steps:
- name: "Checkout source code"
uses: "actions/checkout@v3"
- name: Set up Go
- uses: "actions/checkout@v3"

- name: set up go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: ${{ env.GO_VERSION }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
Expand Down
66 changes: 53 additions & 13 deletions .github/workflows/test.yml → .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,98 @@
name: Go Test
name: Go CI

on:
push:
branches:
- main
pull_request:
release:
types: [published]

env:
GO_VERSION: 1.18

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.45

go_mod_tidy_check:
name: Go Mod Tidy Check
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- run: go mod tidy

- name: check for diff
run: git diff --exit-code

test_coverage:
name: Unit Tests Coverage
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.18"]

steps:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
go-version: ${{ env.GO_VERSION }}

- name: Test & Coverage
run: |
go install github.com/ory/[email protected]
go-acc -o coverage.txt `go list ./... | grep -v node/tests` -- -v
- uses: codecov/[email protected]
with:
file: ./coverage.txt

unit_race_test:
name: Run Unit Tests with Race Detector
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.18"]

steps:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
go-version: ${{ env.GO_VERSION }}

- name: execute test run
run: make test-unit-race

integration_test:
name: Run Integration Tests
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.18"]

steps:
- uses: actions/checkout@v3

- name: set up go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
go-version: ${{ env.GO_VERSION }}

- name: Swamp Tests
run: make test-swamp

- name: Swamp Tests with Race Detector
run: make test-swamp-race
28 changes: 0 additions & 28 deletions .github/workflows/go-mod-tidy.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/lint.yml

This file was deleted.

0 comments on commit 3f2d743

Please sign in to comment.