Skip to content

Commit

Permalink
Simplify GOPATH settings in GH actions (#552)
Browse files Browse the repository at this point in the history
* Add local `setup-gopath` github action and reuse it in other workflows
  * it writes to `$GITHUB_ENV` file to expose new env vars to subsequent steps
  * it creates a symlink `$GOPATH/src/github.com/uber/jaeger-client-go` and exports it as `$PROJECT` var
* other workflows run this action and the only need to do `cd $PROJECT` before running Go commands
* fixed the GOPATH issue for #551, but FOSSA fails for other reasons now
  • Loading branch information
yurishkuro committed Nov 27, 2020
1 parent 4ab51d8 commit 17fd3e8
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 99 deletions.
19 changes: 19 additions & 0 deletions .github/actions/setup-gopath/action.yml
@@ -0,0 +1,19 @@
name: 'Setup GOPATH'
description: 'Link repo into GOPATH and export $PROJECT var'
runs:
using: "composite"
steps:
- name: Setup GOPATH
shell: bash
run: |
export GOPATH=$(go env GOPATH)
export PROJECT=$GOPATH/src/github.com/uber/jaeger-client-go
mkdir -p $(dirname $PROJECT)
ln -s $(pwd) $PROJECT
# write to GH files to make vars available to later steps
echo "PROJECT=$PROJECT" >>"$GITHUB_ENV"
echo "GOPATH=$GOPATH" >>"$GITHUB_ENV"
echo "$GOPATH/bin" >>"$GITHUB_PATH"
# print summary
echo "GOPATH=$GOPATH"
echo "PROJECT=$PROJECT"
52 changes: 19 additions & 33 deletions .github/workflows/crossdoc-integration-test.yml
Expand Up @@ -11,39 +11,25 @@ jobs:
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
PROJECT: github.com/uber/jaeger-client-go

steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: ^1.15

- name: Install dependencies and tools
run: |
export GOPATH=$HOME/go
export PROJECT=$GOPATH/src/${{env.PROJECT}}
mkdir -p $GOPATH
export PATH=$PATH:$(go env GOPATH)/bin
mkdir -p $(dirname $PROJECT)
ln -s $(pwd) $PROJECT
cd $PROJECT
make install-ci USE_DEP=true
dep version
docker-compose version
- name: Run tests
run: |
export GOPATH=$HOME/go
export PROJECT=$GOPATH/src/${{env.PROJECT}}
cd $PROJECT
make crossdock
- name: Dump docker-compose logs
if: ${{ failure() }}
run: |
make crossdock-logs
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Setup GOPATH
uses: ./.github/actions/setup-gopath
- name: Install dependencies and tools
run: |
cd $PROJECT
make install-ci USE_DEP=true
docker-compose version
- name: Run tests
run: |
cd $PROJECT
make crossdock
- name: Dump docker-compose logs
if: ${{ failure() }}
run: |
make crossdock-logs
# TODO publish crossdock image to Docher Hub
6 changes: 3 additions & 3 deletions .github/workflows/fossa.yml
Expand Up @@ -13,14 +13,14 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: "^1.14.x"
# Runs a set of commands to initialize and analyze with FOSSA
- name: Setup GOPATH
uses: ./.github/actions/setup-gopath
- name: run FOSSA analysis
env:
# FOSSA Push-Only API Token
FOSSA_API_KEY: '304657e2357ba57b416b94e6b119131b'
run: |
export GOPATH=$HOME/go
export PATH=$PATH:$(go env GOPATH)/bin
cd $PROJECT
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash
fossa init
fossa analyze
99 changes: 36 additions & 63 deletions .github/workflows/unit-tests.yml
Expand Up @@ -11,73 +11,46 @@ jobs:
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
PROJECT: github.com/uber/jaeger-client-go

steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: ^1.15

- name: Install dependencies and tools
run: |
export GOPATH=$HOME/go
export PROJECT=$GOPATH/src/${{env.PROJECT}}
mkdir -p $GOPATH
export PATH=$PATH:$(go env GOPATH)/bin
mkdir -p $(dirname $PROJECT)
ln -s $(pwd) $PROJECT
cd $PROJECT
make install-ci USE_DEP=true
dep version
- name: Run tests
run: |
export GOPATH=$HOME/go
export PROJECT=$GOPATH/src/${{env.PROJECT}}
export PATH=$PATH:$(go env GOPATH)/bin
cd $PROJECT
make test-ci
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
file: cover.out
fail_ci_if_error: true
verbose: true
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Setup GOPATH
uses: ./.github/actions/setup-gopath
- name: Install dependencies and tools
run: |
cd $PROJECT
make install-ci USE_DEP=true
dep version
- name: Run tests
run: |
cd $PROJECT
make test-ci
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
file: cover.out
fail_ci_if_error: true
verbose: true

unit-tests-glide:
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
PROJECT: github.com/uber/jaeger-client-go

steps:
- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: ^1.15

- name: Install dependencies and tools
run: |
export GOPATH=$HOME/go
export PROJECT=$GOPATH/src/${{env.PROJECT}}
mkdir -p $GOPATH
export PATH=$PATH:$(go env GOPATH)/bin
mkdir -p $(dirname $PROJECT)
ln -s $(pwd) $PROJECT
cd $PROJECT
make install-ci USE_DEP=false USE_GLIDE=true
glide -v
- name: Run tests
run: |
export GOPATH=$HOME/go
export PROJECT=$GOPATH/src/${{env.PROJECT}}
export PATH=$PATH:$(go env GOPATH)/bin
cd $PROJECT
make test-ci
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Setup GOPATH
uses: ./.github/actions/setup-gopath
- name: Install dependencies and tools
run: |
cd $PROJECT
make install-ci USE_DEP=false USE_GLIDE=true
glide -v
- name: Run tests
run: |
cd $PROJECT
make test-ci

0 comments on commit 17fd3e8

Please sign in to comment.