Skip to content

feat: Add external PR safe to test support #479

feat: Add external PR safe to test support

feat: Add external PR safe to test support #479

Workflow file for this run

# Copyright 2024 StreamNative, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Tests
on:
pull_request:
pull_request_target:
types: [labeled]
jobs:
acctest:
name: Run acceptance tests
if: |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
runs-on: ubuntu-latest
env:
ACC_TEST_SERVICE_ACCOUNT: ${{ secrets.ACC_TEST_SERVICE_ACCOUNT }}
GLOBAL_DEFAULT_API_SERVER: https://api.test.cloud.gcp.streamnative.dev
GLOBAL_DEFAULT_AUDIENCE: https://api.test.cloud.gcp.streamnative.dev
GLOBAL_DEFAULT_ISSUER: https://auth.test.cloud.gcp.streamnative.dev/
ACCESS_TOKEN: ${{ secrets.SNBOT_GITHUB_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.22.4
id: go
- name: Setup Git token
run: |
git config --global user.email "[email protected]"
git config --global user.name "StreamNative Bot"
git config --global url."https://streamnativebot:${ACCESS_TOKEN}@github.com/".insteadOf "https://github.com/"
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.7
terraform_wrapper: false
- name: Build the terraform-provider-streamnative
run: |
make build
mkdir -p $HOME/.terraform.d/plugins/linux_amd64
sudo mv terraform-provider-streamnative $HOME/.terraform.d/plugins/linux_amd64/
echo "The terraform-provider-streamnative location:" `readlink -f $HOME/.terraform.d/plugins/linux_amd64/`
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Ready the environment
run: |
echo $ACC_TEST_SERVICE_ACCOUNT > $HOME/service_account.json
- name: Run Acceptance Tests for the Provider
uses: nick-fields/retry@v2
with:
timeout_minutes: 120
max_attempts: 3
retry_on: error
command: |
export KEY_FILE_PATH=$HOME/service_account.json
make testacc