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
Replace travis job with github action. #66
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: build | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
working-directory: ./src/github.com/awalterschulze/gographviz | ||
|
||
steps: | ||
- name: Set GOPATH | ||
run: | | ||
echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)/gographviz" | ||
echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/gographviz/bin" | ||
shell: bash | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.14' | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
path: src/github.com/awalterschulze/gographviz | ||
|
||
- name: Install dependencies | ||
run: make dependencies | ||
working-directory: ${{env.working-directory}} | ||
|
||
- name: Run regenerate | ||
run: make regenerate | ||
working-directory: ${{env.working-directory}} | ||
|
||
- name: Run build | ||
run: make build | ||
working-directory: ${{env.working-directory}} | ||
|
||
- name: Run checkers | ||
run: make checkers | ||
working-directory: ${{env.working-directory}} | ||
|
||
- name: Run testing | ||
run: make test | ||
working-directory: ${{env.working-directory}} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
regenerate: | ||
.PHONY: help regenerate test dependencies build checkers action | ||
|
||
# Prefer tools that we've installed | ||
export PATH := $(HOME)/go/bin:$(PATH) | ||
|
||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
regenerate: ## Re-generate lexers and parsers and pass through goimports | ||
go get github.com/goccmack/gocc | ||
go install github.com/goccmack/gocc | ||
gocc -zip -o ./internal/ dot.bnf | ||
gocc -zip -o ./internal/ dot.bnf | ||
find . -type f -name '*.go' | xargs goimports -w | ||
go mod tidy | ||
|
||
test: | ||
test: ## Perform package tests | ||
go test ./... | ||
|
||
travis: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a really good idea, I forgot about the possibility to run locally... In order to have separated steps in github action, I will add different rules to Makefile ( |
||
make regenerate | ||
go build ./... | ||
go test ./... | ||
dependencies: ## Grab necessary dependencies for checkers | ||
go version | ||
go get golang.org/x/tools/cmd/goimports | ||
go get github.com/kisielk/errcheck | ||
go get -u golang.org/x/lint/golint | ||
go mod tidy | ||
|
||
build: ## Perform build process | ||
go build . | ||
|
||
checkers: ## Run all checkers (errcheck, gofmt and golint) | ||
errcheck -ignore 'fmt:[FS]?[Pp]rint*' ./... | ||
gofmt -l -s -w . | ||
golint -set_exit_status | ||
git diff --exit-code | ||
|
||
action: dependencies regenerate build test checkers ## Run steps of github action |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great 👍
I do not see the regenerate step in github actions.
The
git diff --exit-code
is also used to check that the newest generated code was checked in.Otherwise it looks amazing :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed regenerate.☹️
One question, when I execute
make regenerate
, the created imports forerrors
andtoken
are local paths. I was expecting import withgithub.com/jmrtt/gographviz
or better yet withgithub.com/awalterschulze/gographviz
. So I'm missing something here.The import after running
make regenerate
looks like"home/roquette/gographviz/internal/token"
andgoimport
gives an error as expected. What I'm doing wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that is possible to specify the package in
gocc
command-line using-p
. But it was being ignored since the output is going to./internal
due to https://github.com/goccmack/gocc/blob/65cbc60dd30507e085bed479695e11aaf6fe9c2e/internal/config/config.go#L184So, I changed the makefile to pass the package as parameter and generate inside internal folder (
cd internal; gocc -zip -p github.com/awalterschulze/gographviz/internal ../dot.bnf
). Please check if this is the best way to perform this in my last commit.With this, I updated the generated code and is possible to check using
git diff --exit-code
.Last run of the action can be found in: https://github.com/jmrtt/gographviz/runs/1205227899
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha I think the problem is the
GOPATH
variable needs to be set.I think
gocc
uses theGOPATH
to generate the paths.I think travis used to set this as part of its default go setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with setting the GOPATH we should be able to get away with the old
gocc -zip -o ./internal/ dot.bnf
which should then also remove the generated txt files, I hope at least.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it seems it uses the
go/build
package to figure out the default packagehttps://github.com/goccmack/gocc/blob/master/internal/config/config.go#L205
I think I still remember encouraging this idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting in this much effort.
I think this work is needed and I do appreciate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the all the information! 😄 I will revert my last commit and try setting GOPATH to have
gocc -zip -o ./internal/ dot.bnf
back. I'll let you know when have a new iteration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With GOPATH and correct location, only
token.go
was updated by regenerate. Generated txt files didn't appear.So, we already have the regeneration step and github actions working correctly (needed to set GOPATH and working directory to have it working).
Last run of github actions with regenerate: https://github.com/jmrtt/gographviz/runs/1205882765
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work.
Well done, this looks great.
I think with time of not having a working CI, the token.go got outdated some how. So including in the pull request makes sense :)