2022-09-02 05:40:13 +00:00
|
|
|
name: Build Binaries
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
ref:
|
|
|
|
required: true
|
|
|
|
description: "GitHub ref to use"
|
|
|
|
type: string
|
|
|
|
os:
|
|
|
|
required: true
|
|
|
|
description: "Target OS (i.e.: GOOS)"
|
|
|
|
type: string
|
|
|
|
arch:
|
|
|
|
required: true
|
2022-10-26 08:18:39 +00:00
|
|
|
description: "Target Architecture (i.e.: GOARCH)"
|
2022-09-02 05:40:13 +00:00
|
|
|
type: string
|
|
|
|
build-platform:
|
|
|
|
required: false
|
|
|
|
default: ubuntu-latest
|
|
|
|
description: 'Build platform (i.e.: runs-on) for job'
|
|
|
|
type: string
|
2023-12-13 17:25:14 +00:00
|
|
|
dev-version:
|
|
|
|
required: false
|
|
|
|
description: "Dev version to bake into the binary"
|
|
|
|
type: string
|
2022-09-02 05:40:13 +00:00
|
|
|
version:
|
|
|
|
required: true
|
|
|
|
description: "Version to produce"
|
|
|
|
type: string
|
2022-09-14 01:52:21 +00:00
|
|
|
version-set:
|
2022-09-02 05:40:13 +00:00
|
|
|
required: false
|
2022-09-14 01:52:21 +00:00
|
|
|
description: "Set of language versions to use for builds, lints, releases, etc."
|
2022-09-02 05:40:13 +00:00
|
|
|
type: string
|
ci: Track code coverage
**Overview**
This re-enables tracking of code coverage.
For Go, there are two kinds of coverage at play:
unit test and integration test coverage.
Unit tests follow the usual pattern of running
`go test -cover -coverprofile=whatever.cov`.
For integration tests, we use the new integration test profiling support
[added in Go 1.20](https://go.dev/testing/coverage/).
In short, the way it works is:
# Build a coverage instrumented binary:
go build -cover
# Set GOCOVERDIR to a directory and run the integration tests
# that will invoke this coverage-instrumented binary.
GOCOVERDIR=$(pwd)/coverage
go test ./tests
# $GOCOVERDIR will now be filled with coverage data
# from every invocation of the coverage-instrumented binary.
# Combine it into a single coverage file:
go tool covdata textfmt -i=$(GOCOVERDIR) -o=out.cov
# The resulting file can be uploaded to codecov as-is.
The above replaces the prior, partially working hacks we had in place
to get coverage-instrumented binaries with `go test -c`
and hijacking the TestMain.
**Notable changes**
- TestMain hijacking is deleted from the Pulumi CLI.
We no longer need this to build coverage-instrumented binaries.
- ProgramTest no longer tracks or passes PULUMI_TEST_COVERAGE_PATH
because the Pulumi binary no longer accepts a test.coverprofile flag.
This information is now in the GOCOVERDIR environment variable.
- We add an `enable-coverage` parameter to the `ci-build-binaries`
workflow to mirror some of the other workflows.
It will produce coverage-instrumented binaries if this is true.
These binaries are then used by `ci-run-test` which will set
`GOCOVERDIR` and merge the coverage results from it.
- Coverage configuration no longer counts tests, testdata,
and Protobuf-generated code against coverage.
- go-wrapper.sh:
Because we're no longer relying on the `go test -c` hack,
this no longer excludes Windows and language providers
from coverage tracking.
- go-test.py and go-wrapper.sh will include pulumi-language-go and
pulumi-language-nodejs in covered packages.
*Other changes*
- go-test.py:
Fixed a bug where `args` parameters added for coverage were ignored.
Note that this change DOES NOT track coverage for calls made to Pulumi
packages by plugins downloaded from external sources,
e.g. provider plugins. Arguably, that's out of scope of coverage
trackcing for the Pulumi repository.
Resolves #8615, #11419
2023-06-27 16:57:36 +00:00
|
|
|
enable-coverage:
|
|
|
|
description: "Build coverage instrumented binaries"
|
|
|
|
default: false
|
|
|
|
required: false
|
|
|
|
type: boolean
|
2024-04-11 15:58:42 +00:00
|
|
|
enable-race-detection:
|
|
|
|
description: "Build binaries with race detection"
|
|
|
|
default: false
|
|
|
|
required: false
|
|
|
|
type: boolean
|
2022-09-02 05:40:13 +00:00
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
name: ${{ inputs.os }}-${{ inputs.arch }}
|
|
|
|
runs-on: ${{ inputs.build-platform }}
|
|
|
|
|
2022-11-08 11:13:27 +00:00
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
|
2022-09-02 05:40:13 +00:00
|
|
|
steps:
|
|
|
|
- name: "Windows cache workaround"
|
|
|
|
# https://github.com/actions/cache/issues/752#issuecomment-1222415717
|
|
|
|
# but only modify the path by adding tar.exe
|
2022-09-14 01:52:21 +00:00
|
|
|
if: ${{ runner.os == 'Windows' }}
|
2022-09-02 05:40:13 +00:00
|
|
|
env:
|
|
|
|
TOOL_BIN: ${{ runner.temp }}/tar-bin
|
|
|
|
run: |
|
|
|
|
set -x
|
|
|
|
mkdir -p "${TOOL_BIN}"
|
|
|
|
cp "C:/Program Files/Git/usr/bin/tar.exe" "${TOOL_BIN}"
|
|
|
|
PATH="${TOOL_BIN}:${PATH}"
|
|
|
|
echo "$TOOL_BIN" | tee -a "$GITHUB_PATH"
|
|
|
|
command -v tar
|
|
|
|
tar --version
|
2024-03-30 15:53:47 +00:00
|
|
|
- uses: actions/checkout@v4
|
2022-09-02 05:40:13 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ inputs.ref }}
|
2022-09-14 01:52:21 +00:00
|
|
|
- name: Configure Go Cache Key
|
2022-09-02 05:40:13 +00:00
|
|
|
env:
|
2023-07-06 17:37:08 +00:00
|
|
|
CACHE_KEY: "${{ fromJson(inputs.version-set).go }}-${{ runner.os }}-${{ runner.arch }}"
|
2022-09-02 05:40:13 +00:00
|
|
|
run: echo "$CACHE_KEY" > .gocache.tmp
|
2024-03-29 16:00:53 +00:00
|
|
|
- uses: actions/setup-go@v5
|
2022-09-02 05:40:13 +00:00
|
|
|
with:
|
2022-09-14 01:52:21 +00:00
|
|
|
go-version: ${{ fromJson(inputs.version-set).go }}
|
2022-09-02 05:40:13 +00:00
|
|
|
cache: true
|
|
|
|
cache-dependency-path: |
|
|
|
|
pkg/go.sum
|
|
|
|
.gocache.tmp
|
|
|
|
- name: Setup versioning env vars
|
|
|
|
run: |
|
|
|
|
./scripts/versions.sh | tee -a "${GITHUB_ENV}"
|
|
|
|
- name: Install GoReleaser
|
|
|
|
uses: goreleaser/goreleaser-action@v3
|
|
|
|
with:
|
|
|
|
install-only: true
|
|
|
|
distribution: goreleaser-pro
|
2023-06-29 05:02:46 +00:00
|
|
|
# TODO[pulumi/pulumi#13312: Change this to not pin to a version after
|
|
|
|
# addressing the root cause of why GoReleaser v1.19.0 fails to read
|
|
|
|
# the configuration.
|
|
|
|
version: v1.18.2
|
2022-09-16 16:43:45 +00:00
|
|
|
- name: Set up bin dir
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
|
|
|
|
GOOS: ${{ inputs.os }}
|
|
|
|
GOARCH: ${{ inputs.arch }}
|
|
|
|
run: ./scripts/prep-for-goreleaser.sh local
|
|
|
|
- name: Show files and permissions
|
|
|
|
if: ${{ runner.os != 'macOS'}}
|
|
|
|
run: find bin -type f -printf "%M %p/"\\n
|
|
|
|
- name: Show files and permissions
|
|
|
|
if: ${{ runner.os == 'macOS'}}
|
2022-09-02 05:40:13 +00:00
|
|
|
run: |
|
2022-09-16 16:43:45 +00:00
|
|
|
brew install findutils
|
|
|
|
gfind bin -type f -printf "%M %p/"\\n
|
2022-09-02 05:40:13 +00:00
|
|
|
- name: Package
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
GORELEASER_CURRENT_TAG: v${{ inputs.version }}
|
2023-12-13 17:25:14 +00:00
|
|
|
PULUMI_VERSION: ${{ inputs.dev-version || inputs.version }}
|
ci: Track code coverage
**Overview**
This re-enables tracking of code coverage.
For Go, there are two kinds of coverage at play:
unit test and integration test coverage.
Unit tests follow the usual pattern of running
`go test -cover -coverprofile=whatever.cov`.
For integration tests, we use the new integration test profiling support
[added in Go 1.20](https://go.dev/testing/coverage/).
In short, the way it works is:
# Build a coverage instrumented binary:
go build -cover
# Set GOCOVERDIR to a directory and run the integration tests
# that will invoke this coverage-instrumented binary.
GOCOVERDIR=$(pwd)/coverage
go test ./tests
# $GOCOVERDIR will now be filled with coverage data
# from every invocation of the coverage-instrumented binary.
# Combine it into a single coverage file:
go tool covdata textfmt -i=$(GOCOVERDIR) -o=out.cov
# The resulting file can be uploaded to codecov as-is.
The above replaces the prior, partially working hacks we had in place
to get coverage-instrumented binaries with `go test -c`
and hijacking the TestMain.
**Notable changes**
- TestMain hijacking is deleted from the Pulumi CLI.
We no longer need this to build coverage-instrumented binaries.
- ProgramTest no longer tracks or passes PULUMI_TEST_COVERAGE_PATH
because the Pulumi binary no longer accepts a test.coverprofile flag.
This information is now in the GOCOVERDIR environment variable.
- We add an `enable-coverage` parameter to the `ci-build-binaries`
workflow to mirror some of the other workflows.
It will produce coverage-instrumented binaries if this is true.
These binaries are then used by `ci-run-test` which will set
`GOCOVERDIR` and merge the coverage results from it.
- Coverage configuration no longer counts tests, testdata,
and Protobuf-generated code against coverage.
- go-wrapper.sh:
Because we're no longer relying on the `go test -c` hack,
this no longer excludes Windows and language providers
from coverage tracking.
- go-test.py and go-wrapper.sh will include pulumi-language-go and
pulumi-language-nodejs in covered packages.
*Other changes*
- go-test.py:
Fixed a bug where `args` parameters added for coverage were ignored.
Note that this change DOES NOT track coverage for calls made to Pulumi
packages by plugins downloaded from external sources,
e.g. provider plugins. Arguably, that's out of scope of coverage
trackcing for the Pulumi repository.
Resolves #8615, #11419
2023-06-27 16:57:36 +00:00
|
|
|
PULUMI_BUILD_MODE: ${{ inputs.enable-coverage && 'coverage' || 'normal' }}
|
2024-04-11 15:58:42 +00:00
|
|
|
PULUMI_ENABLE_RACE_DETECTION: ${{ inputs.enable-race-detection && 'true' || 'false' }}
|
2022-09-02 05:40:13 +00:00
|
|
|
run: |
|
|
|
|
set -euxo pipefail
|
|
|
|
# Spurious, this command requires piping via stdin
|
|
|
|
# shellcheck disable=SC2002
|
|
|
|
cat .goreleaser.yml \
|
|
|
|
| go run github.com/t0yv0/goreleaser-filter@v0.3.0 -goos ${{ inputs.os }} -goarch ${{ inputs.arch }} \
|
2023-12-11 16:29:14 +00:00
|
|
|
| goreleaser release -f - -p 5 --skip-validate --clean --snapshot
|
2022-09-02 05:40:13 +00:00
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: artifacts-cli-${{ inputs.os }}-${{ inputs.arch }}
|
|
|
|
retention-days: 1
|
|
|
|
path: |
|
|
|
|
goreleaser/*.tar.gz
|
|
|
|
goreleaser/*.zip
|