forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build the provider in github (GoogleCloudPlatform#9351)
- Loading branch information
1 parent
8069927
commit 1f4be80
Showing
6 changed files
with
378 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: build | ||
permissions: read-all | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
repo: | ||
description: 'Repository to build' | ||
required: true | ||
type: string | ||
|
||
concurrency: | ||
group: ${{ inputs.repo }}-${{ github.event_name == 'pull_request' && format('pr-{0}-', github.event.pull_request.number) || format('commit-{0}', github.sha) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
generate-repository: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
BASE_BRANCH: ${{ github.event.pull_request.base.ref || github.ref }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 | ||
with: | ||
ruby-version: '3.1' | ||
|
||
- name: Cache Bundler gems | ||
uses: actions/cache@v2 | ||
with: | ||
path: mmv1/vendor/bundle | ||
key: ${{ runner.os }}-gems-${{ hashFiles('mmv1/**/Gemfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-gems- | ||
- name: Install Ruby dependencies | ||
run: | | ||
bundle config path mmv1/vendor/bundle | ||
bundle install | ||
working-directory: mmv1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '^1.19' | ||
|
||
# Cache Go modules | ||
- name: Cache Go modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- run: go install golang.org/x/tools/cmd/goimports@latest | ||
|
||
- name: Build ${{ inputs.repo }} | ||
run: | | ||
set -e | ||
set -x | ||
# Set GOPATH to a directory the runner user has access to | ||
export GOPATH=~/go | ||
function clone_repo() { | ||
export OUTPUT_PATH=$GOPATH/src/github.com/$UPSTREAM_OWNER/$GH_REPO | ||
GITHUB_PATH=https://x-access-token:$GITHUB_TOKEN@github.com/$UPSTREAM_OWNER/$GH_REPO | ||
mkdir -p "$(dirname $OUTPUT_PATH)" | ||
git clone $GITHUB_PATH $OUTPUT_PATH --branch $BASE_BRANCH | ||
} | ||
GH_REPO="${{ inputs.repo }}" | ||
if [ "$GH_REPO" == "docs-examples" ] && [ "$BASE_BRANCH" == "main" ]; then | ||
BASE_BRANCH="master" | ||
fi | ||
GITHUB_PATH=https://x-access-token:$GITHUB_TOKEN@github.com/$UPSTREAM_OWNER/$GH_REPO | ||
if [[ "$GH_REPO" == terraform-provider-google* ]]; then | ||
UPSTREAM_OWNER=hashicorp | ||
clone_repo | ||
if [ "$GH_REPO" == "terraform-provider-google" ]; then | ||
export VERSION=ga | ||
else | ||
export VERSION=beta | ||
fi | ||
make clean-provider | ||
make provider | ||
elif [ "$GH_REPO" == "terraform-google-conversion" ]; then | ||
UPSTREAM_OWNER=GoogleCloudPlatform | ||
clone_repo | ||
make clean-tgc | ||
make tgc | ||
elif [ "$GH_REPO" == "docs-examples" ]; then | ||
UPSTREAM_OWNER=terraform-google-modules | ||
clone_repo | ||
make tf-oics | ||
else | ||
echo "case not supported" | ||
exit 1 | ||
fi | ||
(current_dir=$(pwd) && cd $OUTPUT_PATH && zip -r "$current_dir/output.zip" .) | ||
- name: Upload built artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: artifact-${{ inputs.repo }} | ||
path: output.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: downstreams | ||
permissions: read-all | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- 'FEATURE-BRANCH-*' | ||
|
||
concurrency: | ||
group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('commit-{0}', github.sha) }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
|
||
terraform-provider-google: | ||
uses: ./.github/workflows/build-downstream.yml | ||
with: | ||
repo: 'terraform-provider-google' | ||
terraform-provider-google-beta: | ||
uses: ./.github/workflows/build-downstream.yml | ||
with: | ||
repo: 'terraform-provider-google-beta' | ||
terraform-google-conversion: | ||
uses: ./.github/workflows/build-downstream.yml | ||
with: | ||
repo: 'terraform-google-conversion' | ||
docs-examples: | ||
uses: ./.github/workflows/build-downstream.yml | ||
with: | ||
repo: 'docs-examples' | ||
|
||
unit-test-terraform-provider-google: | ||
name: terraform-provider-google | ||
needs: terraform-provider-google | ||
uses: ./.github/workflows/unit-test-tpg.yml | ||
with: | ||
repo: 'terraform-provider-google' | ||
|
||
unit-test-terraform-provider-googele-beta: | ||
name: terraform-provider-google-beta | ||
needs: terraform-provider-google-beta | ||
uses: ./.github/workflows/unit-test-tpg.yml | ||
with: | ||
repo: 'terraform-provider-google-beta' | ||
|
||
unit-test-terraform-google-conversion: | ||
name: terraform-google-conversion | ||
needs: [terraform-google-conversion, terraform-provider-google-beta] | ||
uses: ./.github/workflows/unit-test-tgc.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: unit-test-tgc | ||
permissions: read-all | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
compile-and-unit-tests: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Download built artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: artifact-terraform-google-conversion | ||
path: artifacts-tgc | ||
|
||
- name: Download built artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: artifact-terraform-provider-google-beta | ||
path: artifacts-tpgb | ||
|
||
- name: Unzip the artifacts and delete the zip | ||
run: | | ||
unzip artifacts-tgc/output.zip -d ./tgc | ||
unzip artifacts-tpgb/output.zip -d ./tpgb | ||
rm artifacts-tgc/output.zip | ||
rm artifacts-tpgb/output.zip | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '^1.19' | ||
|
||
- name: Cache Go modules and build cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-test-terraform-google-conversion-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-test-terraform-google-conversion-${{ hashFiles('**/go.sum') }} | ||
${{ runner.os }}-test-terraform-google-conversion- | ||
- name: Build Terraform Google Conversion | ||
run: | | ||
cd tgc | ||
go mod edit -replace=github.com/hashicorp/terraform-provider-google-beta=../tpgb | ||
go mod tidy | ||
make build | ||
- name: Run Unit Tests | ||
run: | | ||
cd tgc | ||
make test |
Oops, something went wrong.