Skip to content

Bump actions/setup-python from 5.1.1 to 5.2.0 (#408) #885

Bump actions/setup-python from 5.1.1 to 5.2.0 (#408)

Bump actions/setup-python from 5.1.1 to 5.2.0 (#408) #885

Workflow file for this run

name: Run Go Tests
on:
# Trigger the workflow on push or pull request,
# but only for the master branch.
push:
branches:
- master
pull_request:
types: [opened, reopened, edited, synchronize]
branches:
- master
# Also trigger when a new release has been created.
release:
types: [created, edited, published]
jobs:
# This separate step is required for the project's go-version to be exported
# for use in the following job's matrix.
project-go-version:
name: Export project go version
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.go.outputs.go-version }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set Go version
id: go
run: echo "::set-output name=go-version::$(cat .go-version)"
install-and-run:
name: Tests Go ${{ matrix.go-version }} ${{ matrix.name }}
needs: project-go-version
runs-on: ubuntu-latest
env:
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
strategy:
matrix:
# Versions tested: Project version, version before latest, latest, pre-release
go-version:
[
"${{ needs.project-go-version.outputs.go-version }}",
"1.16.x",
]
prerelease: [false]
# Uncomment to provide early feedback if something breaks in the next Go release.
# TODO(temikus): Golang makes rc versions unavailable after a release so perhaps
# a better workflow is needed here than hardcoding the version.
#
#include:
# - name: "(Pre-release)"
# go-version: "1.16.0-rc1"
# prerelease: true
# Prevent GHA from cancelling other matrix jobs if one fails
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Go with ${{ matrix.go-version }}
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
stable: "false"
- name: Set up gcloud datastore emulator
# JRE is needed for the datastore emulator
run: |
curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-427.0.0-linux-x86_64.tar.gz | tar xfz - -C $HOME
$HOME/google-cloud-sdk/bin/gcloud components install beta cloud-datastore-emulator
sudo apt-get update
sudo apt-get install openjdk-8-jre-headless
- name: Run tests
# Since pre-release branches can be unstable we ignore test errors and
# still mark the workflow run as successful. This prevents pre-release
# test failures from blocking PR merges.
# TODO: Remove below setting when workflows have "allow-failure" option.
# See: https://github.com/actions/toolkit/issues/399
continue-on-error: ${{ matrix.prerelease }}
run: |
echo "Sourcing Google Cloud SDK path helper..."
source $HOME/google-cloud-sdk/path.bash.inc
echo "Downloading go modules..."
go mod download
echo "Installing development deps..."
go install -v github.com/go-bindata/go-bindata/v3/go-bindata
go install -v github.com/golang/mock/mockgen
echo "Running go tests..."
go test -v -timeout=60s ./...
echo "Running go tests again with JSON output for annotations..."
go test -v -timeout=60s -json ./... > test.json
echo "Running gofmt..."
gofmt -w $(go list -f '{{.Dir}}' ./...)
echo "Running go generate..."
go generate -v ./...
- name: Annotate Tests
# Annotate failed tests
if: always()
uses: guyarb/[email protected]
with:
test-results: test.json
- name: Remove test output
# Remove the test output so it does not interfere with the following
# step.
if: always()
run: rm test.json
- name: Check that `gofmt` and `go generate` resulted in no diffs.
# TODO: Remove below setting when workflows have "allow-failure" option.
# See: https://github.com/actions/toolkit/issues/399
continue-on-error: ${{ matrix.prerelease }}
run: |
status=$(git status --porcelain)
if [[ -n ${status} ]]; then
echo "Regenerated files differ from checked-in versions: ${status}"
git status
git diff
exit 1
fi