Skip to content

Commit

Permalink
Make build_sdk a reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrbradley committed Jun 10, 2024
1 parent 60a627f commit f97e59e
Show file tree
Hide file tree
Showing 22 changed files with 441 additions and 1,374 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "Build SDK"

on:
workflow_call: {}

jobs:
build_sdk:
name: build_sdk
runs-on: #{{ if .Config.runner.buildSdk }}##{{- .Config.runner.buildSdk }}##{{ else }}##{{- .Config.runner.default }}##{{ end }}#
strategy:
fail-fast: true
matrix:
language:
- nodejs
- python
- dotnet
- go
- java
steps:
- name: Checkout Repo
uses: #{{ .Config.actionVersions.checkout }}#
#{{- if .Config.checkoutSubmodules }}#
with:
submodules: #{{ .Config.checkoutSubmodules }}#
#{{- end }}#
- uses: pulumi/provider-version-action@v1
with:
set-env: 'PROVIDER_VERSION'
- name: Cache examples generation
uses: actions/cache@v4
with:
path: |
.pulumi/examples-cache
key: ${{ runner.os }}-${{ hashFiles('provider/go.sum') }}
- name: Install pulumictl
uses: #{{ .Config.actionVersions.installGhRelease }}#
with:
tag: #{{ .Config.actionVersions.pulumictlTag }}#
repo: pulumi/pulumictl
- name: Setup Node
uses: #{{ .Config.actionVersions.setupNode }}#
with:
node-version: #{{ .Config.env.NODEVERSION }}#
registry-url: https://registry.npmjs.org
- name: Setup DotNet
uses: #{{ .Config.actionVersions.setupDotNet }}#
with:
dotnet-version: #{{ .Config.env.DOTNETVERSION | toYaml | indent 8 }}#
- name: Setup Python
uses: #{{ .Config.actionVersions.setupPython }}#
with:
python-version: #{{ .Config.env.PYTHONVERSION }}#
- name: Setup Java
uses: #{{ .Config.actionVersions.setupJava }}#
with:
cache: gradle
distribution: temurin
java-version: #{{ .Config.env.JAVAVERSION }}#
- name: Setup Gradle
uses: #{{ .Config.actionVersions.setupGradle }}#
with:
gradle-version: #{{ .Config.env.GRADLEVERSION }}#
- name: Download provider + tfgen binaries
uses: #{{ .Config.actionVersions.downloadArtifact }}#
with:
name: #{{ .Config.provider }}#-provider.tar.gz
path: ${{ github.workspace }}/bin
- name: Untar provider binaries
run: >-
tar -zxf ${{ github.workspace }}/bin/provider.tar.gz -C ${{
github.workspace}}/bin
find ${{ github.workspace }} -name "pulumi-*-#{{ .Config.provider }}#" -print -exec chmod +x {} \;
- name: Install plugins
run: make install_plugins
- name: Update path
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"
- name: Build SDK
run: make build_${{ matrix.language }}
- name: Check worktree clean
uses: pulumi/git-status-check-action@v1
#{{- if .Config.worktreeAllowedChanges }}#
with:
allowed-changes: |
#{{ .Config.worktreeAllowedChanges | indent 12 }}#
#{{- end }}#
- name: Compress SDK folder
run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} .
- name: Upload artifacts
uses: #{{ .Config.actionVersions.uploadArtifact }}#
with:
name: ${{ matrix.language }}-sdk.tar.gz
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz
retention-days: 30
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: #{{ .Config.actionVersions.notifySlack }}#
with:
author_name: Failure in building ${{ matrix.language }} sdk
fields: repo,commit,author,action
status: ${{ job.status }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ jobs:
build_sdk:
name: build_sdk
needs: prerequisites
runs-on: #{{ if .Config.runner.buildSdk }}##{{- .Config.runner.buildSdk }}##{{ else }}##{{- .Config.runner.default }}##{{ end }}#
steps:
- name: Checkout Repo
uses: #{{ .Config.actionVersions.checkout }}#
#{{- if .Config.checkoutSubmodules }}#
with:
submodules: #{{ .Config.checkoutSubmodules }}#
#{{- end }}#
#{{ .Splices.build_sdk }}#
uses: ./.github/workflows/build_sdk.yml
secrets: inherit

generate_coverage_data:
continue-on-error: true
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ jobs:
build_sdk:
name: build_sdk
needs: prerequisites
runs-on: #{{ if .Config.runner.buildSdk }}##{{- .Config.runner.buildSdk }}##{{ else }}##{{- .Config.runner.default }}##{{ end }}#
steps:
- name: Checkout Repo
uses: #{{ .Config.actionVersions.checkout }}#
#{{- if .Config.checkoutSubmodules }}#
with:
submodules: #{{ .Config.checkoutSubmodules }}#
#{{- end }}#
#{{ .Splices.build_sdk }}#
uses: ./.github/workflows/build_sdk.yml
secrets: inherit

prerequisites:
uses: ./.github/workflows/prerequisites.yml
secrets: inherit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ jobs:
build_sdk:
name: build_sdk
needs: prerequisites
runs-on: #{{ if .Config.runner.buildSdk }}##{{- .Config.runner.buildSdk }}##{{ else }}##{{- .Config.runner.default }}##{{ end }}#
steps:
- name: Checkout Repo
uses: #{{ .Config.actionVersions.checkout }}#
#{{- if .Config.checkoutSubmodules }}#
with:
submodules: #{{ .Config.checkoutSubmodules }}#
#{{- end }}#
#{{ .Splices.build_sdk }}#
uses: ./.github/workflows/build_sdk.yml
secrets: inherit

#{{ if .Config.lint -}}#
lint:
name: lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ jobs:
build_sdk:
name: build_sdk
needs: prerequisites
runs-on: #{{ if .Config.runner.buildSdk }}##{{- .Config.runner.buildSdk }}##{{ else }}##{{- .Config.runner.default }}##{{ end }}#
steps:
- name: Checkout Repo
uses: #{{ .Config.actionVersions.checkout }}#
#{{- if .Config.checkoutSubmodules }}#
with:
submodules: #{{ .Config.checkoutSubmodules }}#
#{{- end }}#
#{{ .Splices.build_sdk }}#
uses: ./.github/workflows/build_sdk.yml
secrets: inherit

#{{ if .Config.publishRegistry -}}#
create_docs_build:
name: create_docs_build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@ jobs:
github.event.pull_request.head.repo.full_name == github.repository
name: build_sdk
needs: prerequisites
runs-on: #{{ if .Config.runner.buildSdk }}##{{- .Config.runner.buildSdk }}##{{ else }}##{{- .Config.runner.default }}##{{ end }}#
steps:
- name: Checkout Repo
uses: #{{ .Config.actionVersions.checkout }}#
with:
ref: ${{ env.PR_COMMIT_SHA }}
#{{- if .Config.checkoutSubmodules }}#
submodules: #{{ .Config.checkoutSubmodules }}#
#{{- end }}#
#{{ .Splices.build_sdk }}#
uses: ./.github/workflows/build_sdk.yml
secrets: inherit

comment-notification:
if: github.event_name == 'repository_dispatch'
name: comment-notification
Expand Down
101 changes: 101 additions & 0 deletions provider-ci/test-workflows/aws/.github/workflows/build_sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "Build SDK"

on:
workflow_call: {}

jobs:
build_sdk:
name: build_sdk
runs-on: pulumi-ubuntu-8core
strategy:
fail-fast: true
matrix:
language:
- nodejs
- python
- dotnet
- go
- java
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
submodules: true
- uses: pulumi/provider-version-action@v1
with:
set-env: 'PROVIDER_VERSION'
- name: Cache examples generation
uses: actions/cache@v4
with:
path: |
.pulumi/examples-cache
key: ${{ runner.os }}-${{ hashFiles('provider/go.sum') }}
- name: Install pulumictl
uses: jaxxstorm/action-install-gh-release@v1.11.0
with:
tag: v0.0.46
repo: pulumi/pulumictl
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: <no value>
registry-url: https://registry.npmjs.org
- name: Setup DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: null
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: <no value>
- name: Setup Java
uses: actions/setup-java@v4
with:
cache: gradle
distribution: temurin
java-version: <no value>
- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
gradle-version: <no value>
- name: Download provider + tfgen binaries
uses: actions/download-artifact@v4
with:
name: aws-provider.tar.gz
path: ${{ github.workspace }}/bin
- name: Untar provider binaries
run: >-
tar -zxf ${{ github.workspace }}/bin/provider.tar.gz -C ${{
github.workspace}}/bin
find ${{ github.workspace }} -name "pulumi-*-aws" -print -exec chmod +x {} \;
- name: Install plugins
run: make install_plugins
- name: Update path
run: echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"
- name: Build SDK
run: make build_${{ matrix.language }}
- name: Check worktree clean
uses: pulumi/git-status-check-action@v1
with:
allowed-changes: |
sdk/**/pulumi-plugin.json
sdk/dotnet/Pulumi.*.csproj
sdk/go/**/pulumiUtilities.go
sdk/nodejs/package.json
sdk/python/pyproject.toml
- name: Compress SDK folder
run: tar -zcf sdk/${{ matrix.language }}.tar.gz -C sdk/${{ matrix.language }} .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.language }}-sdk.tar.gz
path: ${{ github.workspace}}/sdk/${{ matrix.language }}.tar.gz
retention-days: 30
- if: failure() && github.event_name == 'push'
name: Notify Slack
uses: 8398a7/action-slack@v3
with:
author_name: Failure in building ${{ matrix.language }} sdk
fields: repo,commit,author,action
status: ${{ job.status }}
Loading

0 comments on commit f97e59e

Please sign in to comment.