pulumi/.github/workflows/test.yml

373 lines
14 KiB
YAML

name: Tests CLI and SDK binaries.
defaults:
run:
shell: bash
on:
workflow_call:
inputs:
go-version:
description: 'Version of the Go toolchain for the build'
default: '1.17.x'
required: false
type: string
python-version:
description: 'Version of the Python toolchain for the build'
default: '3.9.x'
required: false
type: string
node-version:
description: 'Version of the Node toolchain for the build'
default: '14.x'
required: false
type: string
dotnet-version:
description: 'Version of the .NET toolchain for the build'
default: '3.1.x'
required: false
type: string
enable-coverage:
description: 'Collects coverage stats; requires cov-enabled builds'
default: false
required: false
type: boolean
secrets:
pulumi-access-token:
required: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULUMI_TEST_OWNER: "moolumi"
PULUMI_ACCESS_TOKEN: ${{ secrets.pulumi-access-token }}
PYTHON: python
jobs:
test:
name: Test
strategy:
matrix:
platform:
- ubuntu-latest
- windows-latest
- macos-latest
test-subset:
- integration
- integration-subtests
- codegen
- auto
- etc
fail-fast: false
env:
PULUMI_TEST_SUBSET: ${{ matrix.test-subset }}
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Fetch Tags
run: |
git fetch --quiet --prune --unshallow --tags
- name: Reduce test parallelism
if: ${{ matrix.test-subset == 'integration' && matrix.platform == 'windows-latest' }}
run: |
echo "Setting test parallelism to 1"
echo "TESTPARALLELISM=1" >> $GITHUB_ENV
- name: Enable code coverage
if: ${{ inputs.enable-coverage && (matrix.platform != 'windows-latest') }}
run: |
echo "PULUMI_TEST_COVERAGE_PATH=$(pwd)/coverage" >> $GITHUB_ENV
- name: Set up Make (windows)
if: ${{ matrix.platform == 'windows-latest' }}
run: |
choco install make
- name: Set up Go ${{ inputs.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ inputs.go-version }}
check-latest: true
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Cache
uses: actions/cache@v2
id: go-cache
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ matrix.platform }}-${{ matrix.test-subset }}-go-test-cache-${{ hashFiles('**/go.sum') }}
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ inputs.python-version }}
- name: Set up DotNet ${{ inputs.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ inputs.dotnet-version }}
- name: Set up Node ${{ inputs.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}
- name: Uninstall pre-installed Pulumi (windows)
if: ${{ matrix.platform == 'windows-latest' }}
run: |
chocolatey uninstall pulumi
- name: Install yarn
run: |
npm install -g yarn
- name: Install Python deps
run: |
python -m pip install --upgrade pip requests wheel urllib3 chardet
- name: Setup git
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
- name: Set Go Dep path
run: |
echo "PULUMI_GO_DEP_ROOT=$(dirname $(pwd))" >> $GITHUB_ENV
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.3.1
with:
repo: pulumi/pulumictl
- name: Install gotestsum from source
run: |
go install gotest.tools/gotestsum@latest
env:
GOBIN: ${{ github.workspace }}/bin
# Binary installer for gotestsum does not work because the
# project distributes tarballs for Windows instead of zips
# expected by the action.
#
# - name: Install gotestsum
# uses: jaxxstorm/action-install-gh-release@v1.3.1
# with:
# repo: gotestyourself/gotestsum
# tag: v1.7.0
- name: Install goteststats
uses: jaxxstorm/action-install-gh-release@v1.3.1
with:
repo: t0yv0/goteststats
tag: v0.0.7
- name: Download Pulumi Go Binaries (linux-x64)
if: ${{ matrix.platform == 'ubuntu-latest' }}
uses: actions/download-artifact@v2
with:
name: pulumi-linux-x64
path: artifacts/go
- name: Download Pulumi Go Binaries (darwin-x64)
if: ${{ matrix.platform == 'macos-latest' }}
uses: actions/download-artifact@v2
with:
name: pulumi-darwin-x64
path: artifacts/go
- name: Download Pulumi Go Binaries (windows-x64)
if: ${{ matrix.platform == 'windows-latest' }}
uses: actions/download-artifact@v2
with:
name: pulumi-windows-x64
path: artifacts/go
- name: Install Pulumi Go Binaries (non-windows)
if: ${{ matrix.platform != 'windows-latest' }}
run: |
mkdir -p pulumi-bin
tar -xf artifacts/go/*.tar.gz -C pulumi-bin
mkdir -p bin
mv pulumi-bin/pulumi/* bin/
rm -rf pulumi-bin
- name: Install Pulumi Go Binaries (windows)
if: ${{ matrix.platform == 'windows-latest' }}
run: |
mkdir -p $PWD/bin
unzip -d $PWD/bin artifacts/go/*.zip
mv $PWD/bin/pulumi/bin/* $PWD/bin
rm -rf $PWD/bin/pulumi
echo "Checking contents of $PWD/bin"
find $PWD/bin
- name: Add ./bin to PATH
run: |
LOCAL_PATH=$(./scripts/normpath "${{ github.workspace }}/bin")
echo "Adding LOCAL_PATH=$LOCAL_PATH to PATH"
echo $LOCAL_PATH >> $GITHUB_PATH
- name: Verify Pulumi Version
run: |
which pulumi || echo "no pulumi"
pulumi version || echo "no pulumi"
- name: Download Pulumi .NET NuGet packages
uses: actions/download-artifact@v2
with:
name: pulumi-nuget-packages
# path set to match PULUMI_LOCAL_NUGET
path: ${{ github.workspace }}/nuget
- name: Add NuGet packages as a local NuGet source
run: |
echo "PULUMI_LOCAL_NUGET=$PULUMI_LOCAL_NUGET"
SOURCE=$(./scripts/normpath $PULUMI_LOCAL_NUGET)
echo "SOURCE=$SOURCE"
dotnet nuget add source $SOURCE
env:
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
- name: Inspect downloaded artifacts
run: |
find artifacts
echo "PULUMI_LOCAL_NUGET=$PULUMI_LOCAL_NUGET"
ls $PULUMI_LOCAL_NUGET
env:
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
- name: Ensure dependencies for the Node SDK
run: |
cd sdk/nodejs
make ensure
- name: Build the Node SDK
run: |
cd sdk/nodejs
make build_package
cd bin
yarn link
- name: Ensure dependencies for the Python SDK
run: |
cd sdk/python
make ensure
- name: Install Python SDK
run: |
cd sdk/python
make build_package
- name: python sdk fast tests
run: cd sdk/python && make TEST_ALL_DEPS= test_fast
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: python sdk auto tests
run: cd sdk/python && make TEST_ALL_DEPS= test_auto
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: python sdk go tests
run: cd sdk/python && make TEST_ALL_DEPS= test_go
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: dotnet sdk tests
run: cd sdk/dotnet && make TEST_ALL_DEPS= dotnet_test
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: dotnet sdk auto tests
run: cd sdk/dotnet && make TEST_ALL_DEPS= auto_test
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: dotnet sdk go tests
run: cd sdk/dotnet && make TEST_ALL_DEPS= go_test
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: node sdk sxs tests
run: cd sdk/nodejs && make TEST_ALL_DEPS= sxs_tests
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: node sdk unit tests
run: cd sdk/nodejs && make TEST_ALL_DEPS= unit_tests
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: node sdk auto tests
run: cd sdk/nodejs && make TEST_ALL_DEPS= auto_tests
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: node sdk go tests
run: cd sdk/nodejs && make TEST_ALL_DEPS= go_tests
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: go sdk fast tests
run: cd sdk/go && make TEST_ALL_DEPS= test_fast
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: go sdk auto tests
run: cd sdk/go && make TEST_ALL_DEPS= test_auto
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: build tests
run: make TEST_ALL_DEPS= test_build
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: pkg tests
run: make TEST_ALL_DEPS= test_pkg
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: integration tests
run: make TEST_ALL_DEPS= test_integration
env:
PULUMI_HOME: ${{ github.workspace }}/home
PULUMI_NODE_MODULES: ${{ runner.temp }}/opt/pulumi/node_modules
PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget
PULUMI_ROOT: ${{ runner.temp }}/opt/pulumi
- name: Convert Node coverage data
if: ${{ matrix.platform != 'windows-latest' }}
run: |
cd sdk/nodejs
if [ -e .nyc_output ]; then yarn run nyc report -r cobertura --report-dir $PULUMI_TEST_COVERAGE_PATH; fi
- name: Merge Go coverage data
if: ${{ inputs.enable-coverage && (matrix.platform != 'windows-latest') }}
run: |
pulumictl cover merge --in ./coverage --out ./coverage/go-all.txt
rm ./coverage/*.cov
- name: Upload code coverage
if: ${{ inputs.enable-coverage && (matrix.platform != 'windows-latest') }}
uses: codecov/codecov-action@v2
with:
directory: coverage
files: '*'
fail_ci_if_error: false
verbose: true
- name: Summarize Test Time by Package
run: |
mkdir -p test-results
touch test-results/empty.json # otherwise goteststats fails below when no files match
goteststats -statistic pkg-time test-results/*.json
- name: Summarize Test Times by Indivudal Test
run: |
goteststats -statistic test-time test-results/*.json | head -n 100 || \
if [[ $? -eq 141 ]]; then true; else exit $?; fi