mvdan / github-actions-golang Goto Github PK
View Code? Open in Web Editor NEWGitHub Actions as CI for Go
License: BSD 3-Clause "New" or "Revised" License
GitHub Actions as CI for Go
License: BSD 3-Clause "New" or "Revised" License
in your readme, it specifies to use platform
, but it should be os
.
platform: [ubuntu-latest, macos-latest, windows-latest]
After configuring the ci.yml to this:
env:
GOPRIVATE: "github.com/company"
jobs:
.....
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://YOUR_GITHUB_USERNAME:${TOKEN}@github.com".insteadOf "https://github.com"
I am still saw following error:
go: github.com/company/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /home/runner/go/pkg/mod/cache/vcs/4902ad5423d70bf8a819e419fc1d6e0667f5a8f1542bd02ff6253926ac8fcb35: exit status 128:
remote: Repository not found.
fatal: repository 'https://github.com/company/repo/' not found
Error: Process completed with exit code 1.
If I change uses: actions/checkout@v2
to uses: actions/checkout@v1
seems solve the issue
Is there additional setup required for checkout@v2?
Is it possible to test for Go v1 apps that's not having/using go mod?
This is what I'm getting --
https://github.com/suntong/shuttlebot/runs/2701444155?check_suite_focus=true
Run go test ./...
main.go:16:2: cannot find package "github.com/caarlos0/env" in any of:
/opt/hostedtoolcache/go/1.15.12/x64/src/github.com/caarlos0/env (from $GOROOT)
/home/runner/go/src/github.com/caarlos0/env (from $GOPATH)
logging.go:8:2: cannot find package "github.com/go-kit/kit/log" in any of:
/opt/hostedtoolcache/go/1.15.12/x64/src/github.com/go-kit/kit/log (from $GOROOT)
/home/runner/go/src/github.com/go-kit/kit/log (from $GOPATH)
. . .
Would it be possible that I set my own GOPATH
and do go get
myself?
First, I just wanted to say, huge thanks for this repo/README, it helped me a ton. I've been working on setting up github actions for Caddy.
In your README, you note:
The setup-go action doesn't set PATH, so currently it's not possible to go install a program and run it directly. Until that's fixed, consider absolute paths like $(go env GOPATH)/bin/program.
I just wanted to point out that I figured out that you can just do this on any step after setup-go
, pretty much entirely smoothes that issue over:
echo "::add-path::$(go env GOPATH)/bin"
This is an awesome resource, thank you!
I noticed you use ${{ hashFiles('**/go.sum') }}
as a cache key for the module cache. I am not sure that does what it is intended for, since the go.sum
file does not contain a hash of the module itself, and it might be missing from a module with no dependencies. If hashFiles
includes the file names in the key, you could just use the go.mod
files instead, but even that would exclude modules that did not update.
The private modules section mentions how to make the repositories reachable, but not how to bypass the proxy. Shouldn't it include a GOPRIVATE
env?
When I run this Github Action:
on: [push, pull_request]
name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Redis
# You may pin to the exact commit or the version.
# uses: zhulik/redis-action@765216a54a1114f109ce90a1de4775080be16ea5
uses: zhulik/[email protected]
- name: Setup PostgreSQL
# You may pin to the exact commit or the version.
# uses: Harmon758/postgresql-action@0be19fa37850b22cb4c9bbf28a03abbf44abd863
uses: Harmon758/[email protected]
with:
# POSTGRES_DB - name for the default database that is created
postgresql db: shoppinglistboom
# POSTGRES_USER - create the specified user with superuser power
postgresql user: shoppinglist
# POSTGRES_PASSWORD - superuser password
postgresql password: postgres
- name: Build
working-directory: ./backend
run: go build ./...
- name: Test
working-directory: ./backend
run: go test ./...
env:
DB_HOST: localhost
DB_USER: shoppinglist
DB_DATABASE: shoppinglistboom
DB_PASSWORD: postgres
REDIS_HOST: localhost
REDIS_PORT: 6379
DATABASE_DSN: host=localhost user=shoppinglist password=postgres dbname=shoppinglistboom sslmode=disable
TESTING: true
it fails every time due to the Tests. But when I look at the logs it says that the Tests passed.
It gives me the exit code 2 but I dont know what to do with that.
I used your template for set GOPATH env variable, but there is an error.
- Your workflow file was invalid: The pipeline is not valid. .github/workflows/go.yml (Line: 9, Col: 15): Unrecognized named-value: 'runner'. Located at position 1 within expression: runner.workspace,.github/workflows/go.yml (Line: 26, Col: 7): Unexpected value 'with'
My line 9 has:
GOPATH: ${{ runner.workspace }}
I had the bad experience that this doesn't work on Windows:
- name: Run coverage
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
Output:
no required module provides package .out; to add it:
go get .out
Error: Process completed with exit code 1.
But this works:
- name: Run coverage
run: go test -v -race -coverprofile coverage.out -covermode atomic ./...
The only difference is that =
is replaced with space.
I suspect this is a PowerShell quoting issue.
README recommends deprecated workflow commands like ::set-env
instead of environment files.
The readme says for How do I set up caching between builds?
the path can be ~/go/pkg/mod
.
However it seems that's only for source files to be cached.
If you are like me and you do cross-compilation of binaries to 10+ architectures, you probably need to cache ~/.cache/go-build/
directory as well. Otherwise you're waiting for all Go stdlibs (and deps cached in ~/go/pkg/mod
) to recompile ––which is the majority of the time spent.
Thoughts?
I've found this repo very helpful, thank you! I've noticed that using the actions-cache as demonstrated in the repo doesn't result in tests being cached. I know on my local machine when I rerun tests for packages that haven't changed the results are cached, but when I run on GitHub Actions even with all the cache directories setup the tests aren't cached.
It'd help speed up tests for a lot of Go projects if we could figure that out.
I have some projects using travis and this allowed me to have shields when the project passed.
How can we do this with github actions ?
BTW, thank you very much for your helpful project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.