Skip to content

Commit f1ebb58

Browse files
reusable workflow
1 parent f3b3a5c commit f1ebb58

4 files changed

Lines changed: 114 additions & 33 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@ jobs:
1717
runs-on: ${{ matrix.os }}
1818
strategy:
1919
matrix:
20-
go_version: ['1.26']
2120
os: [ubuntu-latest, windows-latest, macos-latest]
2221
env:
2322
OS: ${{ matrix.os }}
24-
GO: ${{ matrix.go_version }}
23+
GO: '1.26'
2524

2625
steps:
2726
- name: Check out code into the Go module directory
2827
uses: actions/checkout@v6
2928

3029
- name: Dotenv Action
30+
id: dotenv
3131
uses: falti/dotenv-action@v1
3232
with:
3333
path: .github/workflows/env
3434
log-variables: true
3535

36-
- name: Set up Go ${{ matrix.go_version }}
36+
- name: Set up Go ${{ steps.dotenv.outputs.go_version }}
3737
uses: actions/setup-go@v6
3838
with:
39-
go-version: ${{ matrix.go_version }}
39+
go-version: ${{ steps.dotenv.outputs.go_version }}
4040
check-latest: true
4141
cache: true
4242

4343
- name: golangci-lint
4444
uses: golangci/golangci-lint-action@v9
4545
with:
46-
version: v2.11.4
46+
version: ${{ steps.dotenv.outputs.lint_version }}
4747
args: --timeout=30m
4848

4949
- name: Test
@@ -74,30 +74,3 @@ jobs:
7474
token: ${{ secrets.CODECOV_TOKEN }}
7575
report_type: test_results
7676
files: ./unit-tests.xml
77-
78-
test-ssh:
79-
name: Test SSH client
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Check out code into the Go module directory
83-
uses: actions/checkout@v6
84-
85-
- name: Set up Go
86-
uses: actions/setup-go@v6
87-
with:
88-
go-version: 1.26
89-
90-
- name: Run tests
91-
run: |
92-
make start-ssh-server
93-
make ssh-test
94-
make stop-ssh-server
95-
96-
- name: Upload code coverage to Codecov
97-
uses: codecov/codecov-action@v6
98-
with:
99-
name: code-coverage-ssh-report
100-
files: ./coverage-ssh.out
101-
fail_ci_if_error: false
102-
verbose: true
103-
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
GO_VERSION=1.26.2
1+
GO_VERSION=1.26
2+
LINT_VERSION=v2.11.4

.github/workflows/run-tests.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run tests workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
go_version:
10+
required: true
11+
type: string
12+
lint_version:
13+
required: true
14+
type: string
15+
secrets:
16+
GITHUB_TOKEN:
17+
required: true
18+
CODECOV_TOKEN:
19+
required: true
20+
21+
jobs:
22+
build:
23+
name: Build and run test on ${{ inputs.os }}
24+
runs-on: ${{ inputs.os }}
25+
env:
26+
OS: ${{ inputs.os }}
27+
GO: ${{ inputs.go_version }}
28+
29+
steps:
30+
- name: Set up Go ${{ inputs.go_version }}
31+
uses: actions/setup-go@v6
32+
with:
33+
go-version: ${{ inputs.go_version }}
34+
check-latest: true
35+
cache: true
36+
37+
- name: golangci-lint
38+
uses: golangci/golangci-lint-action@v9
39+
with:
40+
version: ${{ inputs.lint_version }}
41+
args: --timeout=30m
42+
43+
- name: Build
44+
run: make build
45+
46+
- name: Test
47+
run: make test-ci
48+
env:
49+
TEST_FUSE: 1
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Upload code coverage to Codecov
53+
uses: codecov/codecov-action@v6
54+
with:
55+
name: code-coverage-report-${{ matrix.os }}
56+
env_vars: OS,GO
57+
files: ./coverage.out
58+
flags: unittests
59+
fail_ci_if_error: false
60+
verbose: true
61+
token: ${{ secrets.CODECOV_TOKEN }}
62+
63+
- name: Upload test results to Codecov
64+
if: ${{ !cancelled() }}
65+
uses: codecov/codecov-action@v6
66+
with:
67+
env_vars: OS,GO
68+
token: ${{ secrets.CODECOV_TOKEN }}
69+
report_type: test_results
70+
files: ./unit-tests.xml

.github/workflows/ubuntu.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and run tests on Linux
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths-ignore:
7+
- 'docs/**'
8+
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
paths-ignore:
12+
- 'docs/**'
13+
14+
jobs:
15+
build:
16+
name: Build and run tests on Linux
17+
runs-on: 'ubuntu-latest'
18+
19+
steps:
20+
- name: Check out code into the Go module directory
21+
uses: actions/checkout@v6
22+
23+
- name: Dotenv Action
24+
id: dotenv
25+
uses: falti/dotenv-action@v1
26+
with:
27+
path: .github/workflows/env
28+
log-variables: true
29+
30+
- name: Build and run tests
31+
uses: ./.github/workflows/run-tests.yml
32+
with:
33+
os: 'ubuntu-latest'
34+
go_version: ${{ steps.dotenv.outputs.go_version }}
35+
lint_version: ${{ steps.dotenv.outputs.lint_version }}
36+
secrets: inherit
37+

0 commit comments

Comments
 (0)