I have a Go project with a Makefile
test:
@go test -cover ./...
and a mod file
module path/to/repo
go 1.19
require github.com/go-chi/chi/v5 v5.0.8
I created a Github action sample to run tests on a Github PR
name: QA on pull request
on: pull_request
jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run tests
run: make test
I would like to know why this workflow is working without a install dependencies
step. The project itself is using external dependencies and I think there should be a step that runs go get ./...
Does Go install them under the hood if not present? Or does the action actions/setup-go@v3
install the dependencies?
CodePudding user response:
According to go test
docs (or you may run go help test
locally to read its description):
'Go test' recompiles each package along with any files with names matching the file pattern "*_test.go".
It also installs all the dependencies; so, it happens when the action does go test
. You can probably observe it in the logs.
actions/setup-go@v3
doesn't depend on the code itself. It just sets up the go
environment you ask for. In your setup, if you swap the setup-go
and checkout
, it still works.