Fix failing tests (#442)
* Fix failing tests * useless try * try using job dependencies * retry * revert * disable concurrency, try general config/env * use in-job config * don't use home var * individual configs * remove multiline * useless tests * one more try to figure it out * use the right home path * multiline * fix typo * remove unused files, revert conftest changes * Move plugin init to separate action * Remove parallel tests Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com>
This commit is contained in:
parent
56877421ff
commit
3f798d3032
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"type": "service_account",
|
||||
"project_id": "test-only"
|
||||
}
|
|
@ -25,6 +25,8 @@ on:
|
|||
- test
|
||||
|
||||
env:
|
||||
TF_PLUGIN_CACHE_DIR: "/home/runner/.terraform.d/plugin-cache"
|
||||
GOOGLE_APPLICATION_CREDENTIALS: "/home/runner/credentials.json"
|
||||
PYTEST_ADDOPTS: "--color=yes"
|
||||
|
||||
jobs:
|
||||
|
@ -33,38 +35,32 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Config auth
|
||||
run: |
|
||||
echo '{"type": "service_account", "project_id": "test-only"}' \
|
||||
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.9"
|
||||
|
||||
- name: Set up Terraform
|
||||
uses: hashicorp/setup-terraform@v1
|
||||
with:
|
||||
terraform_version: 1.1.3
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Set environment
|
||||
run: |
|
||||
echo "TF_PLUGIN_CACHE_DIR=${{ github.workspace }}/.terraform.d/plugin-cache-${GITHUB_JOB}" >> $GITHUB_ENV
|
||||
echo "GOOGLE_APPLICATION_CREDENTIALS=${GITHUB_WORKSPACE}/.github/workflows/fake-key.json" >> $GITHUB_ENV
|
||||
mkdir --parents ${{ github.workspace }}/.terraform.d/plugin-cache-${GITHUB_JOB}
|
||||
terraform -chdir=tests providers lock
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r tests/requirements.txt
|
||||
|
||||
|
||||
- name: Run tests on documentation examples
|
||||
id: doc-examples
|
||||
run: |
|
||||
pytest -n 4 -vv tests/doc_examples
|
||||
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
|
||||
pip install -r tests/requirements.txt
|
||||
pytest -vv tests/doc_examples
|
||||
|
||||
examples:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Config auth
|
||||
run: |
|
||||
echo '{"type": "service_account", "project_id": "test-only"}' \
|
||||
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
|
@ -73,30 +69,25 @@ jobs:
|
|||
- name: Set up Terraform
|
||||
uses: hashicorp/setup-terraform@v1
|
||||
with:
|
||||
terraform_version: 1.1.3
|
||||
terraform_version: 1.1.4
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Set environment
|
||||
run: |
|
||||
echo "TF_PLUGIN_CACHE_DIR=${{ github.workspace }}/.terraform.d/plugin-cache-${GITHUB_JOB}" >> $GITHUB_ENV
|
||||
echo "GOOGLE_APPLICATION_CREDENTIALS=${GITHUB_WORKSPACE}/.github/workflows/fake-key.json" >> $GITHUB_ENV
|
||||
mkdir --parents ${{ github.workspace }}/.terraform.d/plugin-cache-${GITHUB_JOB}
|
||||
terraform -chdir=tests providers lock
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r tests/requirements.txt
|
||||
|
||||
|
||||
- name: Run tests environments
|
||||
id: test-environments
|
||||
run: |
|
||||
pytest -n 4 -vv tests/examples
|
||||
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
|
||||
pip install -r tests/requirements.txt
|
||||
pytest -vv tests/examples
|
||||
|
||||
modules:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Config auth
|
||||
run: |
|
||||
echo '{"type": "service_account", "project_id": "test-only"}' \
|
||||
| tee -a $GOOGLE_APPLICATION_CREDENTIALS
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
|
@ -105,21 +96,11 @@ jobs:
|
|||
- name: Set up Terraform
|
||||
uses: hashicorp/setup-terraform@v1
|
||||
with:
|
||||
terraform_version: 1.1.3
|
||||
terraform_version: 1.1.4
|
||||
terraform_wrapper: false
|
||||
|
||||
- name: Set environment
|
||||
run: |
|
||||
echo "TF_PLUGIN_CACHE_DIR=${{ github.workspace }}/.terraform.d/plugin-cache-${GITHUB_JOB}" >> $GITHUB_ENV
|
||||
echo "GOOGLE_APPLICATION_CREDENTIALS=${GITHUB_WORKSPACE}/.github/workflows/fake-key.json" >> $GITHUB_ENV
|
||||
mkdir --parents ${{ github.workspace }}/.terraform.d/plugin-cache-${GITHUB_JOB}
|
||||
terraform -chdir=tests providers lock
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -r tests/requirements.txt
|
||||
|
||||
|
||||
- name: Run tests modules
|
||||
id: test-modules
|
||||
run: |
|
||||
pytest -n 4 -vv --ignore=tests/modules/examples tests/modules
|
||||
run: |
|
||||
mkdir -p ${{ env.TF_PLUGIN_CACHE_DIR }}
|
||||
pip install -r tests/requirements.txt
|
||||
pytest -vv tests/modules
|
||||
|
|
|
@ -38,15 +38,11 @@ def _plan_runner():
|
|||
|
||||
fixture_parent = os.path.dirname(fixture_path)
|
||||
fixture_prefix = os.path.basename(fixture_path) + "_"
|
||||
tf_lock = os.path.join(BASEDIR, 'tests/.terraform.lock.hcl')
|
||||
tf_lock_use = os.path.isfile(tf_lock)
|
||||
with tempfile.TemporaryDirectory(prefix=fixture_prefix,
|
||||
dir=fixture_parent) as tmp_path:
|
||||
# copy fixture to a temporary directory so we can execute
|
||||
# multiple tests in parallel
|
||||
shutil.copytree(fixture_path, tmp_path, dirs_exist_ok=True)
|
||||
if tf_lock_use:
|
||||
os.symlink(tf_lock, os.path.join(tmp_path, '.terraform.lock.hcl'))
|
||||
tf = tftest.TerraformTest(tmp_path, BASEDIR,
|
||||
os.environ.get('TERRAFORM', 'terraform'))
|
||||
tf.setup(upgrade=True)
|
||||
|
|
|
@ -16,9 +16,7 @@ from pathlib import Path
|
|||
|
||||
import marko
|
||||
|
||||
|
||||
MODULES_PATH = Path(__file__).parents[2] / 'modules/'
|
||||
print(MODULES_PATH)
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
|
|
|
@ -2,4 +2,3 @@ pytest>=6.2.5
|
|||
PyYAML>=6.0
|
||||
tftest>=1.6.3
|
||||
marko>=1.2.0
|
||||
pytest-xdist>=2.5.0
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
|
||||
terraform {
|
||||
required_version = ">= 1.0.0"
|
||||
required_providers {
|
||||
archive = {
|
||||
source = "registry.terraform.io/hashicorp/archive"
|
||||
version = ">= 2.2.0"
|
||||
}
|
||||
google = {
|
||||
source = "hashicorp/google"
|
||||
version = ">= 4.6.0"
|
||||
}
|
||||
google-beta = {
|
||||
source = "hashicorp/google-beta"
|
||||
version = ">= 4.6.0"
|
||||
}
|
||||
local = {
|
||||
source = "registry.terraform.io/hashicorp/local"
|
||||
version = ">= 2.1.0"
|
||||
}
|
||||
random = {
|
||||
source = "registry.terraform.io/hashicorp/random"
|
||||
version = ">= 3.1.0"
|
||||
}
|
||||
time = {
|
||||
source = "registry.terraform.io/hashicorp/time"
|
||||
version = ">= 0.7.2"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue