cloud-foundation-fabric/.github/workflows/tests.yml

181 lines
5.2 KiB
YAML
Raw Normal View History

2023-02-25 04:08:30 -08:00
# Copyright 2023 Google LLC
2021-10-26 23:24:45 -07:00
#
# 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.
2022-01-01 06:52:31 -08:00
name: "Tests"
2021-10-27 07:08:29 -07:00
on:
# schedule:
# - cron: "45 2 * * *"
2021-10-26 23:24:45 -07:00
pull_request:
branches:
- master
tags:
- ci
- test
2021-10-26 23:28:10 -07:00
2021-10-27 07:08:29 -07:00
env:
GOOGLE_APPLICATION_CREDENTIALS: "/home/runner/credentials.json"
2021-10-27 07:08:29 -07:00
PYTEST_ADDOPTS: "--color=yes"
2022-08-31 06:28:15 -07:00
PYTHON_VERSION: "3.10"
2022-04-12 12:03:20 -07:00
TF_PLUGIN_CACHE_DIR: "/home/runner/.terraform.d/plugin-cache"
2023-02-25 04:08:30 -08:00
TF_VERSION: 1.3.9
2021-10-27 07:08:29 -07:00
2021-10-26 23:24:45 -07:00
jobs:
2022-10-25 07:58:37 -07:00
examples:
2021-10-26 23:24:45 -07:00
runs-on: ubuntu-latest
steps:
2023-02-25 04:08:30 -08:00
- uses: actions/checkout@v3
2021-10-26 23:24:45 -07:00
- name: Config auth
run: |
echo '{"type": "service_account", "project_id": "test-only"}' \
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
2021-10-26 23:24:45 -07:00
- name: Set up Python
2023-02-25 04:08:30 -08:00
uses: actions/setup-python@v4
2021-10-26 23:24:45 -07:00
with:
2022-04-12 12:03:20 -07:00
python-version: ${{ env.PYTHON_VERSION }}
2023-02-25 04:08:30 -08:00
cache: 'pip'
cache-dependency-path: 'tests/requirements.txt'
2022-02-05 08:10:43 -08:00
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TF_VERSION }}
terraform_wrapper: false
# avoid conflicts with user-installed providers on local machines
- name: Pin provider versions
run: |
for f in $(find . -name versions.tf); do
sed -i 's/>=\(.*# tftest\)/=\1/g' $f;
done
- name: Run tests on documentation examples
2022-04-12 12:03:20 -07:00
id: pytest
2021-10-26 23:24:45 -07:00
run: |
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
pip install -r tests/requirements.txt
pytest -vv tests/examples
2021-10-26 23:24:45 -07:00
2022-10-25 07:58:37 -07:00
blueprints:
2021-10-26 23:24:45 -07:00
runs-on: ubuntu-latest
steps:
2023-02-25 04:08:30 -08:00
- uses: actions/checkout@v3
2021-10-26 23:24:45 -07:00
- name: Config auth
run: |
echo '{"type": "service_account", "project_id": "test-only"}' \
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
2021-10-26 23:24:45 -07:00
- name: Set up Python
2023-02-25 04:08:30 -08:00
uses: actions/setup-python@v4
2021-10-26 23:24:45 -07:00
with:
2022-04-12 12:03:20 -07:00
python-version: ${{ env.PYTHON_VERSION }}
2023-02-25 04:08:30 -08:00
cache: 'pip'
cache-dependency-path: 'tests/requirements.txt'
2021-10-26 23:24:45 -07:00
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
2021-10-26 23:24:45 -07:00
with:
2022-04-12 12:03:20 -07:00
terraform_version: ${{ env.TF_VERSION }}
2021-10-26 23:24:45 -07:00
terraform_wrapper: false
2022-02-05 08:10:43 -08:00
# avoid conflicts with user-installed providers on local machines
- name: Pin provider versions
run: |
for f in $(find . -name versions.tf); do
sed -i 's/>=\(.*# tftest\)/=\1/g' $f;
done
- name: Run tests environments
2022-04-12 12:03:20 -07:00
id: pytest
2021-10-26 23:24:45 -07:00
run: |
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
pip install -r tests/requirements.txt
pytest -vv tests/blueprints
2021-10-26 23:24:45 -07:00
2022-01-10 11:12:25 -08:00
modules:
2021-10-26 23:24:45 -07:00
runs-on: ubuntu-latest
steps:
2023-02-25 04:08:30 -08:00
- uses: actions/checkout@v3
2021-10-26 23:24:45 -07:00
- name: Config auth
run: |
echo '{"type": "service_account", "project_id": "test-only"}' \
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
2021-10-26 23:24:45 -07:00
- name: Set up Python
2023-02-25 04:08:30 -08:00
uses: actions/setup-python@v4
2021-10-26 23:24:45 -07:00
with:
2022-04-12 12:03:20 -07:00
python-version: ${{ env.PYTHON_VERSION }}
2023-02-25 04:08:30 -08:00
cache: 'pip'
cache-dependency-path: 'tests/requirements.txt'
2021-10-26 23:24:45 -07:00
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
2021-10-26 23:24:45 -07:00
with:
2022-04-12 12:03:20 -07:00
terraform_version: ${{ env.TF_VERSION }}
2021-10-26 23:24:45 -07:00
terraform_wrapper: false
2022-02-05 08:10:43 -08:00
# avoid conflicts with user-installed providers on local machines
- name: Pin provider versions
run: |
for f in $(find . -name versions.tf); do
sed -i 's/>=\(.*# tftest\)/=\1/g' $f;
done
2021-10-27 05:28:51 -07:00
- name: Run tests modules
2022-04-12 12:03:20 -07:00
id: pytest
2022-02-05 08:10:43 -08:00
run: |
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
pip install -r tests/requirements.txt
pytest -vv tests/modules
2022-04-12 12:03:20 -07:00
fast:
runs-on: ubuntu-latest
steps:
2023-02-25 04:08:30 -08:00
- uses: actions/checkout@v3
2022-04-12 12:03:20 -07:00
- name: Config auth
run: |
echo '{"type": "service_account", "project_id": "test-only"}' \
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
- name: Set up Python
2023-02-25 04:08:30 -08:00
uses: actions/setup-python@v4
2022-04-12 12:03:20 -07:00
with:
python-version: ${{ env.PYTHON_VERSION }}
2023-02-25 04:08:30 -08:00
cache: 'pip'
cache-dependency-path: 'tests/requirements.txt'
2022-04-12 12:03:20 -07:00
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
2022-04-12 12:03:20 -07:00
with:
terraform_version: ${{ env.TF_VERSION }}
terraform_wrapper: false
# avoid conflicts with user-installed providers on local machines
- name: Pin provider versions
run: |
for f in $(find . -name versions.tf); do
sed -i 's/>=\(.*# tftest\)/=\1/g' $f;
done
2022-04-12 12:03:20 -07:00
- name: Run tests on FAST stages
id: pytest
run: |
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
pip install -r tests/requirements.txt
pytest -vv tests/fast