pulumi/.github/workflows/run-build-and-acceptance-te...

225 lines
7.4 KiB
YAML

on:
repository_dispatch:
types: [ run-acceptance-tests-command ]
pull_request:
paths-ignore:
- 'CHANGELOG.md'
- 'CHANGELOG_PENDING.md'
defaults:
run:
shell: bash
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_PROD_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULUMI_TEST_OWNER: "moolumi"
PR_COMMIT_SHA: ${{ github.event.client_payload.pull_request.head.sha }}
PYTHON: python
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
# Cancel checks on prior commits when new commits are added to a PR.
# This is motivated by temporary throughput issues on our GitHub
# Actions workers availability.
#
# Note from GitHub docs: Concurrency is currently in beta and subject
# to change.
#
# See also: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency
#
# Note on the the `group` computed expression: it is compiling
# `github.head_ref == '' ? github.run_id : github.head_ref` expression
# to the primitives available in GitHub Actions. The idea to use
# `head_ref` on `pull_request` triggers, but use unique
# `github.run_id` on `run-acceptance-tests-command` triggers. This
# effectively disables `concurrency` checks for
# `run-acceptance-tests-command` triggers.
concurrency:
group: run-build-acceptance-tests-${{(fromJSON(format('[{0},{1}]',toJSON(github.head_ref),toJSON(github.run_id))))[github.head_ref=='']}}
cancel-in-progress: true
jobs:
comment-notification:
# We only care about adding the result to the PR if it's a repository_dispatch event
if: github.event_name == 'repository_dispatch'
runs-on: ubuntu-latest
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Update with Result
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
Please view the results of the PR Build + Acceptance Tests Run [Here][1]
[1]: ${{ steps.vars.outputs.run-url }}
go-lint:
# See https://github.com/pulumi/pulumi/issues/9280 for why this is set to v1.44
container: golangci/golangci-lint:v1.44
name: Lint ${{ matrix.directory }}
strategy:
matrix:
directory: [ sdk, pkg, tests ]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Lint ${{ matrix.directory }}
run: |
cd ${{ matrix.directory }} && golangci-lint run -c ../.golangci.yml
protobuf-lint:
name: Check Protobufs
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
# This till display missing pulumictl errors, but it won't prevent the lint from working.
- name: Check Protobufs
run: |
make check-proto
sdk-lint:
name: Lint SDKs
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.17.x]
python-version: [3.9.x]
dotnet-version: [3.1.x]
node-version: [14.x]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
ref: ${{ env.PR_COMMIT_SHA }}
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.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
if: ${{ runner.os != 'Windows' }} # Note [Windows Go Cache] in build.yml
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-cache-${{ hashFiles('*/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: sdk/python/requirements.txt
- name: Set up DotNet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
- run: mkdir -p ${{ runner.temp }}/opt/pulumi/nuget
- name: Add NuGet packages as a local NuGet source
run: |
echo $(which dotnet)
echo $(dotnet --version)
dotnet nuget add source ${{ runner.temp }}/opt/pulumi/nuget
- name: Set up Node ${{ inputs.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache-dependency-path: sdk/nodejs/package.json
- 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: Update path
run: |
echo "${{ runner.temp }}/opt/pulumi/bin" >> $GITHUB_PATH
- name: Fetch Tags
run: |
git fetch --quiet --prune --unshallow --tags
- 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.7.1
with:
repo: pulumi/pulumictl
tag: v0.0.32
cache: enable
- name: Ensure
run: |
make ensure
- name: Lint Node
run: |
cd sdk/nodejs && make lint
- name: Lint Python
run: |
cd sdk/python && make lint
- name: Lint .NET
run: |
cd sdk/dotnet && make lint
versions:
name: Versions
uses: ./.github/workflows/versions.yml
build:
name: Build
uses: ./.github/workflows/build.yml
needs: versions
with:
enable-coverage: true
goreleaser-flags: -p 3 --skip-validate
test-linux:
name: Test Linux
needs: build
uses: ./.github/workflows/test-fast.yml
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
with:
enable-coverage: true
platform: ubuntu-latest
secrets:
pulumi-access-token: ${{ secrets.PULUMI_PROD_ACCESS_TOKEN }}
test-macos:
name: Test MacOS
needs: build
uses: ./.github/workflows/test-minimal.yml
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
with:
enable-coverage: true
platform: macos-latest
secrets:
pulumi-access-token: ${{ secrets.PULUMI_PROD_ACCESS_TOKEN }}
test-windows:
name: Test Windows
needs: build
uses: ./.github/workflows/test-minimal.yml
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
with:
enable-coverage: true
platform: windows-latest
secrets:
pulumi-access-token: ${{ secrets.PULUMI_PROD_ACCESS_TOKEN }}