Skip to content

depsync: add xk6-depsync command #128

depsync: add xk6-depsync command

depsync: add xk6-depsync command #128

Workflow file for this run

# Used as inspiration: https://github.com/mvdan/github-actions-golang
name: Cross-Platform Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
strategy:
# Default is true, cancels jobs for other platforms in the matrix if one fails
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go-version: [ 1.18.x, 1.19.x ]
# Set some variables per OS, usable via ${{ matrix.VAR }}
# XK6_BIN_PATH: the path to the compiled k6 binary, for artifact publishing
# SUCCESS: the typical value for $? per OS (Windows/pwsh returns 'True')
include:
- os: ubuntu-latest
XK6_BIN_PATH: ./cmd/xk6/xk6
SUCCESS: 0
- os: macos-latest
XK6_BIN_PATH: ./cmd/xk6/xk6
SUCCESS: 0
- os: windows-latest
XK6_BIN_PATH: ./cmd/xk6/xk6.exe
SUCCESS: 'True'
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
- name: Print Go version and environment
id: vars
shell: bash
run: |
printf "Using go at: $(which go)\n"
printf "Go version: $(go version)\n"
printf "\n\nGo environment:\n\n"
go env
printf "\n\nSystem environment:\n\n"
env
# Calculate the short SHA1 hash of the git commit
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "go_cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache the build cache
uses: actions/cache@v3
with:
path: ${{ steps.vars.outputs.go_cache }}
key: ${{ runner.os }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-ci
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build xk6
working-directory: ./cmd/xk6
env:
CGO_ENABLED: 0
run: |
go build -trimpath -ldflags="-w -s" -v
- name: Publish Build Artifact
uses: actions/upload-artifact@v3
with:
name: xk6_${{ runner.os }}_${{ steps.vars.outputs.short_sha }}
path: ${{ matrix.XK6_BIN_PATH }}
- name: Run tests
run: |
go test -v -coverprofile="cover-profile.out" -short -race ./...
golangci-lint:
name: runner / golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.19.x
check-latest: true
- name: Retrieve golangci-lint version
run: |
echo "Version=$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')" >> $GITHUB_OUTPUT
id: version
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ steps.version.outputs.Version }}