forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (115 loc) · 4.96 KB
/
ci-test-go.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Run tests for a Go project
run-name: "${{ inputs.project-directory }} ${{ inputs.go-version }} ${{ inputs.platform }}"
on:
workflow_call:
inputs:
go-version:
required: true
type: string
description: "The version of Go to use for the test."
platform:
required: true
type: string
description: "The platform to run the test on."
fail-fast:
required: false
type: boolean
default: true
description: "Fail the workflow if any of the jobs fail."
project-directory:
required: true
type: string
default: "."
description: "The directory where the Go project is located."
rootless-docker:
required: false
type: boolean
default: false
description: "Run the test with rootless docker."
run-tests:
required: false
type: boolean
default: true
description: "Run the tests under conditions controlled by the caller workflow."
ryuk-disabled:
required: false
type: boolean
default: false
description: "Disable the ryuk container for the test."
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
test-go-project:
name: "${{ inputs.project-directory }}/${{ inputs.platform }}/${{ inputs.go-version }}"
runs-on: ${{ inputs.platform }}
continue-on-error: ${{ !inputs.fail-fast }}
env:
TESTCONTAINERS_RYUK_DISABLED: "${{ inputs.ryuk-disabled }}"
steps:
- name: Setup rootless Docker
if: ${{ inputs.rootless-docker }}
uses: ScribeMD/rootless-docker@6bd157a512c2fafa4e0243a8aa87d964eb890886 # v0.2.2
- name: Remove Docket root socket
if: ${{ inputs.rootless-docker }}
run: sudo rm -rf /var/run/docker.sock
- name: Check out code into the Go module directory
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
with:
go-version: '${{ inputs.go-version }}'
cache-dependency-path: '${{ inputs.project-directory }}/go.sum'
id: go
- name: golangci-lint
# TODO: Remove each example/module once it passes the golangci-lint
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["examples/cockroachdb", "examples/toxiproxy", "modules/compose", "modules/pulsar", "modules/redis"]'), inputs.project-directory) }}
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.54.1
# Optional: working directory, useful for monorepos
working-directory: ${{ inputs.project-directory }}
# Optional: golangci-lint command line arguments.
args: --verbose
# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
skip-cache: true
- name: modVerify
working-directory: ./${{ inputs.project-directory }}
run: go mod verify
- name: modTidy
working-directory: ./${{ inputs.project-directory }}
run: make tools-tidy
- name: ensure compilation
working-directory: ./${{ inputs.project-directory }}
run: go build
- name: go test
# only run tests on linux, there are a number of things that won't allow the tests to run on anything else
# many (maybe, all?) images used can only be build on Linux, they don't have Windows in their manifest, and
# we can't put Windows Server in "Linux Mode" in Github actions
# another, host mode is only available on Linux, and we have tests around that, do we skip them?
if: ${{ inputs.run-tests }}
working-directory: ./${{ inputs.project-directory }}
timeout-minutes: 30
run: |
go install gotest.tools/gotestsum@latest
make test-unit
- name: Upload SonarCloud files
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && inputs.run-tests && !inputs.rootless-docker }}
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: sonarcloud
path: |
./sonar-project.properties
${{ inputs.project-directory }}/TEST-unit.xml
${{ inputs.project-directory }}/coverage.out
- name: Run checker
run: |
./scripts/check_environment.sh
- name: Test Summary
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2
with:
paths: "**/${{ inputs.project-directory }}/TEST-unit*.xml"
if: always()