Skip to content

Commit

Permalink
new way of doing things
Browse files Browse the repository at this point in the history
  • Loading branch information
szachovy committed Jun 28, 2024
1 parent 1ce0a6c commit efaded9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 60 deletions.
34 changes: 10 additions & 24 deletions .github/workflows/static-tests.yml → .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Static Tests
name: Style

on:
push:
Expand All @@ -8,31 +8,13 @@ jobs:
setup:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.10.12"

- name: Install Python dependencies
run: pip install --no-cache-dir --user pylint mypy flake8

- name: Cache plugin dir
uses: actions/cache@v3
with:
path: ~/.tflint.d/plugins
key: tflint-${{ hashFiles('.tflint.hcl') }}

- name: Setup Terraform linter
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.51.1

- name: Initialize Terraform linter
run: tflint --init
working-directory: ./tests/setup
run: pip install --no-cache-dir --user pylint==3.2.4 mypy==1.10.1 flake8==7.1.0

run-markdown-lint:
runs-on: self-hosted
Expand Down Expand Up @@ -66,16 +48,20 @@ jobs:
runs-on: self-hosted
needs: setup
steps:
- uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.51.1

- name: Lint Terraform testing infrastructure
run: tflint
run: "tflint --init && tflint"
working-directory: ./tests/setup

run-ansible-lint:
runs-on: self-hosted
needs: setup
steps:
- name: Lint ansible testing playbook
uses: ansible/ansible-lint@main
uses: ansible/ansible-lint@v24.6.1

run-python-pylint:
runs-on: self-hosted
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,51 @@
name: Stateful Tests
name: Tests

on:
push:
branches: '**'

env:
TERRAFORM_WORKING_DIR: ./tests/setup
ANSIBLE_WORKING_DIR: ./tests/testsuite

jobs:
setup:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.10.12"

- name: Install Python dependencies
run: pip install --no-cache-dir --user ansible==9.5.1

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.0.10"

Check failure on line 20 in .github/workflows/tests.yml

View workflow job for this annotation

GitHub Actions / run-ansible-lint

yaml[trailing-spaces]

Trailing spaces
- name: Initialize Terraform infrastructure
run: terraform init
working-directory: ${{ env.TERRAFORM_WORKING_DIR }}

Check failure on line 24 in .github/workflows/tests.yml

View workflow job for this annotation

GitHub Actions / run-ansible-lint

yaml[trailing-spaces]

Trailing spaces
- name: Apply Terraform infrastructure
run: terraform apply --auto-approve
working-directory: ${{ env.TERRAFORM_WORKING_DIR }}

- name: test
run: mv $(whereis terraform | awk '{print $2}') /usr/local/bin

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "16"

tests:
testsuite:
runs-on: self-hosted
needs: setup
env:
TERRAFORM_WORKING_DIR: ./tests/setup
ANSIBLE_WORKING_DIR: ./tests/testsuite
steps:
- name: Initialize Terraform infrastructure
run: terraform init
working-directory: ${{ env.TF_WORKING_DIR }}
- uses: actions/setup-python@v3
with:
python-version: "3.10.12"

- name: Apply Terraform infrastructure
run: terraform apply --auto-approve
working-directory: ${{ env.TF_WORKING_DIR }}
- name: Install Python dependencies
run: pip install --no-cache-dir --user ansible==9.5.1

- name: Run Ansible testsuite
run: ansible-playbook --inventory inventory.yml deploy.yml
working-directory: ${{ env.ANSIBLE_WORKING_DIR }}

cleanup:
runs-on: self-hosted
needs: testsuite
steps:
- name: Destroy Terraform environment
if: always()
run: terraform destroy --auto-approve
working-directory: ${{ env.TF_WORKING_DIR }}
working-directory: ${{ env.TERRAFORM_WORKING_DIR }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![Stateful Tests](https://github.com/szachovy/superset-cluster/actions/workflows/stateful-tests.yml/badge.svg)
![Static Tests](https://github.com/szachovy/superset-cluster/actions/workflows/static-tests.yml/badge.svg)
![Tests](https://github.com/szachovy/superset-cluster/actions/workflows/stateful-tests.yml/badge.svg)

Check failure on line 1 in README.md

View workflow job for this annotation

GitHub Actions / run-markdown-lint

First line in a file should be a top-level heading [Context: "![Tests](https://github.com/sz..."]
![Style](https://github.com/szachovy/superset-cluster/actions/workflows/static-tests.yml/badge.svg)
![System Tests Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/szachovy/d4fd269e226b0ed70954f861129a2756/raw/superset-cluster-codecoverage.json)

# superset-cluster
Expand Down
13 changes: 12 additions & 1 deletion tests/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,23 @@ Ansible playbook running testsuite against applied terraform infrastructure, tha

### Required software

Testing host is the `ubuntu:22.04` runner with the [software installed](../README.md#installed-software) meeting the [required criteria](../README.md/#hosts-specification) with the following software installed for testing:
Testing host is the `ubuntu:22.04` runner (specs ...) with the [software installed](../README.md#installed-software) meeting the [required criteria](../README.md/#hosts-specification) with the following software installed for testing:

* `terraform v1.0.10`
* `python v3.10.12` with the following third party packages:
* `ansible v9.5.1`

Optionally, the following software is installed for doing style checks, and is present in the [automated testing](https://github.com/szachovy/superset-cluster/actions):

* `pylint v3.2.4`
* `mypy v1.10.1 (compiled)`
* `flake8 v7.1.0`
* `markdownlint-cli v0.41.0`
* `shellcheck v0.8.0`
* `hadolint v2.12.2`
* `ansible-lint v24.6.1`
* `tflint v0.51.1`

Testing does not require any additional modules on the terraform initiated infrastructure, current versions of deployed software has been described in the project's [`README.md`](../README.md/#installed-software).

### Usage
Expand Down

0 comments on commit efaded9

Please sign in to comment.