Add go install
compatibility (#23)
#61
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
name: Run tests and example config | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
run_test: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install plugin framework and example plugins | |
run: | | |
pip install ./python-plugins ./example/plugin-example | |
- name: Run all pre-commit hooks | |
run: | | |
pip install pre-commit | |
# Install tfsec | |
curl -s https://raw.githubusercontent.com/aquasecurity/tfsec/master/scripts/install_linux.sh | bash | |
# Install tflint | |
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash | |
pre-commit run --all | |
if: matrix.os == 'ubuntu-latest' | |
- uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_wrapper: false | |
- name: Install Go toolchain | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: "go.mod" | |
cache-dependency-path: "go.sum" | |
- name: Code Consistency Checks | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
output=$(gofmt -l .) | |
echo "$output" | |
test -z $output | |
- name: Generate Binary Name | |
id: binary_name | |
shell: bash | |
run: | | |
binary_name="infra-tester" | |
if [[ ${{ matrix.os }} == "windows-latest" ]]; then | |
binary_name="${binary_name}.exe" | |
fi | |
echo "binary_name=$binary_name" >> "$GITHUB_OUTPUT" | |
- name: Compile Test Binary | |
run: | | |
go build -o bin/${{ steps.binary_name.outputs.binary_name }} | |
- name: Run Example Terraform Tests | |
run: | | |
cd example | |
../bin/${{ steps.binary_name.outputs.binary_name }} "-test.v" |