From 3f2d74340eb7891dd859a493ce636cb989d825c3 Mon Sep 17 00:00:00 2001 From: John Adler Date: Wed, 6 Jul 2022 07:42:27 -0400 Subject: [PATCH] Unify Go CI. (#890) * Unify CI. * whitespace --- .github/workflows/docker-build.yml | 20 ++++--- .github/workflows/{test.yml => go-ci.yml} | 66 ++++++++++++++++++----- .github/workflows/go-mod-tidy.yml | 28 ---------- .github/workflows/lint.yml | 26 --------- 4 files changed, 66 insertions(+), 74 deletions(-) rename .github/workflows/{test.yml => go-ci.yml} (57%) delete mode 100644 .github/workflows/go-mod-tidy.yml delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 89d6722f60..13cad5a212 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -7,22 +7,25 @@ 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 @@ -30,14 +33,17 @@ jobs: 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: diff --git a/.github/workflows/test.yml b/.github/workflows/go-ci.yml similarity index 57% rename from .github/workflows/test.yml rename to .github/workflows/go-ci.yml index 8211561f80..4d1d7e4ad2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/go-ci.yml @@ -1,24 +1,61 @@ -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/golangci-lint-action@v3.2.0 + 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/go-acc@v0.2.6 @@ -26,33 +63,36 @@ jobs: - uses: codecov/codecov-action@v3.1.0 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 diff --git a/.github/workflows/go-mod-tidy.yml b/.github/workflows/go-mod-tidy.yml deleted file mode 100644 index 836ed44d33..0000000000 --- a/.github/workflows/go-mod-tidy.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Go Mod Tidy Check - -on: - push: - branches: - - main - pull_request: - release: - types: [published] - -env: - GO_VERSION: 1.18 - -jobs: - 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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index aa505e0585..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Go Lint - -on: - push: - branches: - - main - pull_request: - -jobs: - golangci: - strategy: - matrix: - go-version: [1.18.x] - os: [ubuntu-latest] - name: lint - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v3 - - name: golangci-lint - uses: golangci/golangci-lint-action@v3.2.0 - with: - version: v1.45