Skip to content
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

ci: configure environment after installing go #1880

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ if ! has readlink ; then
echo "readlink is not installed"; exit 1
fi

if [ -z "$GOPATH" ]; then
GOPATH=$(go env GOPATH)
export GOPATH
fi


AKASH_ROOT=$(pwd)

export AKASH_ROOT
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand Down Expand Up @@ -51,16 +50,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- name: detect release tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: configure variables
Expand Down
48 changes: 23 additions & 25 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/Users/runner/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
Expand All @@ -39,17 +38,16 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
check-latest: true
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: make bins
- run: make docker-image

Expand All @@ -58,33 +56,31 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: make test-full

coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: make test-coverage
- uses: codecov/codecov-action@v3

Expand All @@ -93,16 +89,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: make deps-tidy
- run: make build
- run: make test-vet
Expand All @@ -116,16 +111,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: make shellcheck

sims:
Expand All @@ -135,16 +129,15 @@ jobs:
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- uses: actions/checkout@v3
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- name: test-sim-nondeterminism
run: make test-sim-nondeterminism
- name: test-sim-import-export
Expand All @@ -159,16 +152,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
Expand All @@ -186,6 +178,13 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- name: Ensure only directories exists in upgrades dir
Expand All @@ -206,16 +205,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- run: |
toolchain=$(cat go.mod | grep toolchain | cut -d ' ' -f 2 | sed 's/go*//')
echo "GOTOOLCHAIN=go${toolchain}" >> $GITHUB_ENV
echo "GOVERSION=${toolchain}" >> $GITHUB_ENV
echo "GOROOT=/opt/hostedtoolcache/go/${toolchain}/x64" >> $GITHUB_ENV
- uses: actions/setup-go@v4
with:
go-version: "${{ env.GOVERSION }}"
- name: set environment
uses: HatsuneMiku3939/direnv-action@v1
- name: configure variables
run: |
test_required=$(./script/upgrades.sh test-required ${{ github.ref }})
Expand Down
16 changes: 4 additions & 12 deletions make/releasing.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ ifeq ($(GORELEASER_MOUNT_CONFIG),true)
GORELEASER_IMAGE := -v $(HOME)/.docker/config.json:/root/.docker/config.json $(GORELEASER_IMAGE)
endif

# if go.mod contains replace for any modules on local filesystem
# mount them into docker during goreleaser build to exactly same path
#REPLACED_MODULES := $(shell go list -mod=readonly -m -f '{{ .Replace }}' all 2>/dev/null | grep -v -x -F "<nil>" | grep "^/")
#ifneq ($(REPLACED_MODULES), )
# GORELEASER_MOUNT_REPLACED := $(foreach mod, $(REPLACED_MODULES), -v $(mod):$(mod)\\)
#endif
#GORELEASER_MOUNT_REPLACED := $(GORELEASER_MOUNT_REPLACED:\\=)

.PHONY: bins
bins: $(BINS)

Expand Down Expand Up @@ -68,9 +60,9 @@ docker-image:
-e DOCKER_IMAGE=$(RELEASE_DOCKER_IMAGE) \
-e GOPATH=/go \
-e GOTOOLCHAIN="$(GOTOOLCHAIN)" \
-v $(GOPATH):/go:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(GO_MOD_NAME) \
-v $(GOPATH):/go \
-v $(AKASH_ROOT):/go/src/$(GO_MOD_NAME) \
-w /go/src/$(GO_MOD_NAME) \
$(GORELEASER_IMAGE) \
-f .goreleaser-docker.yaml \
Expand Down Expand Up @@ -99,9 +91,9 @@ release: gen-changelog
-e DOCKER_IMAGE=$(RELEASE_DOCKER_IMAGE) \
-e GOTOOLCHAIN="$(GOTOOLCHAIN)" \
-e GOPATH=/go \
-v $(GOPATH):/go:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(GO_MOD_NAME) \
-v $(GOPATH):/go \
-v $(AKASH_ROOT):/go/src/$(GO_MOD_NAME) \
-w /go/src/$(GO_MOD_NAME) \
$(GORELEASER_IMAGE) \
-f "$(GORELEASER_CONFIG)" \
Expand Down