From 0c6440b24f42ff63e83be8c8dd491f72f5e156b3 Mon Sep 17 00:00:00 2001 From: ginokent <29125616+ginokent@users.noreply.github.com> Date: Sun, 29 Oct 2023 15:44:55 +0900 Subject: [PATCH] ci: fix misc --- .github/workflows/go-lint.yml | 23 ++++++++++++++--------- .github/workflows/go-mod-tidy.yml | 16 +++++++++++++++- .github/workflows/go-test.yml | 16 +++++++++++++++- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml index a69978a6..f196a4e0 100644 --- a/.github/workflows/go-lint.yml +++ b/.github/workflows/go-lint.yml @@ -48,6 +48,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: DEBUG + shell: bash run: | cat <<'DEBUG_DOC' == DEBUG ======================================================= @@ -59,7 +60,6 @@ jobs: ${{ toJSON(github) }} ================================================================ DEBUG_DOC - shell: bash - name: actions/cache for versenv uses: actions/cache@v3 with: @@ -69,6 +69,7 @@ jobs: restore-keys: | versenv-${{ runner.os }}- - name: Add GITHUB_PATH, GITHUB_ENV + shell: bash run: | # Update GITHUB_PATH cat <> $GITHUB_PATH @@ -79,6 +80,7 @@ jobs: # Update GITHUB_ENV grep -Ev '^\s*$|^\s*#' .versenv.env >> $GITHUB_ENV - name: Setup versenv + shell: bash run: | # Setup versenv direnv allow ${{ env.WORKDIR }} @@ -90,6 +92,7 @@ jobs: go-version-file: ${{ env.WORKDIR }}/go.mod - name: Get Golang info id: golang-info + shell: bash run: | echo "GOVERSION=$(go version | cut -d' ' -f3)" >> "$GITHUB_OUTPUT" echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" @@ -104,14 +107,16 @@ jobs: ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}-${{ hashFiles('**/go.sum') }}- ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}- ${{ runner.os }}-go- - # - name: Run go mod tidy - # if: ${{ steps.setup-go.outputs.cache-hit != 'true' }} - # env: - # DEBIAN_FRONTEND: noninteractive - # # GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} - # working-directory: ${{ env.WORKDIR }} - # run: | - # direnv exec . go-mod-tidy-all + - name: Setup git config for go mod download + env: + DEBIAN_FRONTEND: noninteractive + # GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + working-directory: ${{ env.WORKDIR }} + shell: bash + run: | + set -Eeu -o pipefail -x + direnv allow . + direnv exec . bash -Eeux -o pipefail -c 'echo "${GOPRIVATE:-}${GOPRIVATE+,}" | while read -d , -r LINE; do echo "set git config: ${LINE}"; git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@${LINE}".insteadOf "https://${LINE}"; done' - uses: golangci/golangci-lint-action@v3.7.0 # ref. https://github.com/golangci/golangci-lint-action#how-to-use with: working-directory: ${{ env.WORKDIR }} diff --git a/.github/workflows/go-mod-tidy.yml b/.github/workflows/go-mod-tidy.yml index 429a7122..3fe740cd 100644 --- a/.github/workflows/go-mod-tidy.yml +++ b/.github/workflows/go-mod-tidy.yml @@ -45,6 +45,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.ref }} # needed for gh pr view - name: DEBUG + shell: bash run: | cat <<'DEBUG_DOC' == DEBUG ======================================================= @@ -56,7 +57,6 @@ jobs: ${{ toJSON(github) }} ================================================================ DEBUG_DOC - shell: bash - name: actions/cache for versenv uses: actions/cache@v3 with: @@ -66,6 +66,7 @@ jobs: restore-keys: | versenv-${{ runner.os }}- - name: Add GITHUB_PATH, GITHUB_ENV + shell: bash run: | # Update GITHUB_PATH cat <> $GITHUB_PATH @@ -76,6 +77,7 @@ jobs: # Update GITHUB_ENV grep -Ev '^\s*$|^\s*#' .versenv.env >> $GITHUB_ENV - name: Setup versenv + shell: bash run: | # Setup versenv direnv allow ${{ env.WORKDIR }} @@ -87,6 +89,7 @@ jobs: go-version-file: ${{ env.WORKDIR }}/go.mod - name: Get Golang info id: golang-info + shell: bash run: | echo "GOVERSION=$(go version | cut -d' ' -f3)" >> "$GITHUB_OUTPUT" echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" @@ -101,12 +104,23 @@ jobs: ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}-${{ hashFiles('**/go.sum') }}- ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}- ${{ runner.os }}-go- + - name: Setup git config for go mod download + env: + DEBIAN_FRONTEND: noninteractive + # GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + working-directory: ${{ env.WORKDIR }} + shell: bash + run: | + set -Eeu -o pipefail -x + direnv allow . + direnv exec . bash -Eeux -o pipefail -c 'echo "${GOPRIVATE:-}${GOPRIVATE+,}" | while read -d , -r LINE; do echo "set git config: ${LINE}"; git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@${LINE}".insteadOf "https://${LINE}"; done' - name: Run go mod tidy if: ${{ steps.setup-go.outputs.cache-hit != 'true' }} env: DEBIAN_FRONTEND: noninteractive # GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} working-directory: ${{ env.WORKDIR }} + shell: bash run: | direnv exec . go-mod-tidy-all git config --local user.name "github-actions[bot]" diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 540bd6c4..5a213f72 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -48,6 +48,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: DEBUG + shell: bash run: | cat <<'DEBUG_DOC' == DEBUG ======================================================= @@ -59,7 +60,6 @@ jobs: ${{ toJSON(github) }} ================================================================ DEBUG_DOC - shell: bash - name: actions/cache for versenv uses: actions/cache@v3 with: @@ -90,6 +90,7 @@ jobs: go-version-file: ${{ env.WORKDIR }}/go.mod - name: Get Golang info id: golang-info + shell: bash run: | echo "GOVERSION=$(go version | cut -d' ' -f3)" >> "$GITHUB_OUTPUT" echo "GOCACHE=$(go env GOCACHE)" >> "$GITHUB_OUTPUT" @@ -104,12 +105,25 @@ jobs: ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}-${{ hashFiles('**/go.sum') }}- ${{ runner.os }}-go-${{ steps.golang-info.outputs.GOVERSION }}- ${{ runner.os }}-go- + - name: Setup git config for go mod download + env: + DEBIAN_FRONTEND: noninteractive + # GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} + working-directory: ${{ env.WORKDIR }} + shell: bash + run: | + set -Eeu -o pipefail -x + direnv allow . + direnv exec . bash -Eeux -o pipefail -c 'echo "${GOPRIVATE:-}${GOPRIVATE+,}" | while read -d , -r LINE; do echo "set git config: ${LINE}"; git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@${LINE}".insteadOf "https://${LINE}"; done' - name: Run go test env: DEBIAN_FRONTEND: noninteractive # GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} working-directory: ${{ env.WORKDIR }} + shell: bash run: | + set -Eeu -o pipefail -x + direnv allow . direnv exec . make test - uses: codecov/codecov-action@v3 # ref. https://github.com/codecov/codecov-action#example-workflowyml-with-codecov-action with: