Skip to content

go-test: fix lint/shellcheck quoting issues #38

go-test: fix lint/shellcheck quoting issues

go-test: fix lint/shellcheck quoting issues #38

Workflow file for this run

name: go-test
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
TEST_RESULTS_PATH: /tmp/test-results
permissions:
contents: read
jobs:
linux-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go-version:
- 1.18
permissions:
id-token: write
contents: read
steps:
- name: Setup go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Create test directory
run: |
mkdir -p ${{ env.TEST_RESULTS_PATH }}/packer-plugin-sdk
- name: Setup cache for go modules
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download
- name: Run gofmt
run: |
make fmt-check
- name: Run Go Generate Check
run: |
make generate-check
- name: Install gotestsum
run: go install gotest.tools/gotestsum@v1.8.2
- name: Run Go tests
run: |
PACKAGE_NAMES="$(go list ./...)"
echo "Running $(echo "$PACKAGE_NAMES" | wc -w) packages"
echo "$PACKAGE_NAMES"
echo "$PACKAGE_NAMES" | xargs -I {} gotestsum --format=short-verbose --junitfile "$TEST_RESULTS_PATH"/packer-plugin-sdk/gotestsum-report.xml -- -count 1 -p 2 {};
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: linux test results
path: ${{ env.TEST_RESULTS_PATH }}
windows-tests:
runs-on: windows-latest
strategy:
matrix:
go-version:
- 1.18
permissions:
id-token: write
contents: read
steps:
- name: Run git config #Windows-only
run: git config --global core.autocrlf false
- name: Setup Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Setup cache for go modules
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download
- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@v1.8.2
- name: Run Go tests
shell: bash
run: |
PACKAGE_NAMES="$(go list ./...)"
echo "Running $(echo "$PACKAGE_NAMES" | wc -w) packages"
echo "$PACKAGE_NAMES"
echo "$PACKAGE_NAMES" | xargs -I {} gotestsum --format=short-verbose --junitfile "$TEST_RESULTS_PATH"/packer-plugin-sdk/gotestsum-report.xml -- -count 1 -p 2 {};
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: windows test results
path: ${{ env.TEST_RESULTS_PATH }}
darwin-tests:
runs-on: macos-latest
strategy:
matrix:
go-version:
- 1.18
permissions:
id-token: write
contents: read
steps:
- name: Setup go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Create test directory
run: |
mkdir -p ${{ env.TEST_RESULTS_PATH }}/packer-plugin-sdk
- name: Setup cache for go modules
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download go modules
run: go mod download
- name: Install gotestsum
run: go install gotest.tools/gotestsum@v1.8.2
- name: Run Go tests
run: |
PACKAGE_NAMES="$(go list ./...)"
echo "Running $(echo "$PACKAGE_NAMES" | wc -w) packages"
echo "$PACKAGE_NAMES"
echo "$PACKAGE_NAMES" | xargs -I {} gotestsum --format=short-verbose --junitfile "$TEST_RESULTS_PATH"/packer-plugin-sdk/gotestsum-report.xml -- -count 1 -p 2 {};
# Save coverage report parts
- name: Upload and save artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: macos test results
path: ${{ env.TEST_RESULTS_PATH }}