Skip to content

ci: refactored workflows to simplify them #42

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

Merged
merged 1 commit into from
Feb 12, 2024
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
15 changes: 2 additions & 13 deletions .github/actions/setup-deps/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,11 @@ runs:
using: composite
steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '1.18'
go-version-file: './go.mod'

- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ inputs.token }}

- name: Install docker-compose v2
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
run: |
gh release -R docker/compose download -p docker-compose-linux-x86_64
mv -f docker-compose-linux-x86_64 docker-compose
sudo mv /usr/local/bin/docker-compose /usr/local/bin/docker-compose-v2
sudo install docker-compose /usr/local/bin/
docker-compose --version
23 changes: 0 additions & 23 deletions .github/workflows/base-lint.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/base-test.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: "Lint"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
push:
branches: [ master ]
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Check out code
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: ${{ github.event_name != 'pull_request' }}
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# go validator works pretty bad in super-linter, we'll use the original one
VALIDATE_GO: false

- name: Setup dependencies
uses: ./.github/actions/setup-deps
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint Golang
uses: golangci/golangci-lint-action@v3
with:
only-new-issues: ${{ github.event_name == 'pull_request' }}
args: >
--config=./.github/linters/.golangci.yml
30 changes: 0 additions & 30 deletions .github/workflows/pr-lint.yml

This file was deleted.

16 changes: 9 additions & 7 deletions .github/workflows/pr-test.yml → .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
name: "PR Branch: Test"
name: "Test"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
pull_request:
push:
branches: [ master ]
pull_request:

jobs:
test:
Expand All @@ -16,20 +17,21 @@ jobs:
timeout-minutes: 10
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup dependencies
uses: ./.github/actions/setup-deps
with:
token: ${{secrets.GITHUB_TOKEN}}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Run tests
run: task test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: success()
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
fail_ci_if_error: false
13 changes: 5 additions & 8 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,22 @@ tasks:

test-deps-up:
summary: Starts test dependencies
preconditions:
- sh: docker-compose version --short | grep '^2'
msg: "docker-compose v2 is expected to be installed"
cmds:
- cmd: docker-compose up --detach --wait
- cmd: docker compose up --detach --wait

test-deps-down:
summary: Stops test dependencies
cmds:
- cmd: docker-compose down -v
- cmd: docker compose down -v

test-run:
summary: Runs tests, must have dependencies running in the docker-compose
summary: Runs tests, must have dependencies running in the docker compose
cmds:
- cmd: go test -timeout 2m -cover -coverprofile=coverage.txt -covermode=atomic ./...
vars:
PG_PORT:
# `docker-compose port postgres 5432` -> "0.0.0.0:52041"
sh: docker-compose port postgres 5432 | cut -f2 -d":"
# `docker compose port postgres 5432` -> "0.0.0.0:52041"
sh: docker compose port postgres 5432 | cut -f2 -d":"
env:
PGHOST: localhost
PGPORT: "{{.PG_PORT}}"
Expand Down