Skip to content

fix go-version staling #486

fix go-version staling

fix go-version staling #486

Workflow file for this run

name: Run Tests
on:
pull_request:
branches:
- main
jobs:
terraform_format:
name: Run terraform fmt
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
- name: Format all .tf files recursively
run: |
terraform fmt -check -diff -recursive ${{ github.workspace }}
terraform_docs:
name: Run tfplugindocs
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: '1.20.5' # tfplugindocs requires go >= 1.18
- name: Setup tfplugindocs
run: |
cd /tmp
curl -L -o tfplugindocs.zip https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.15.0/tfplugindocs_0.15.0_linux_amd64.zip
unzip tfplugindocs.zip
chmod +x tfplugindocs
- name: Generate tf docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
rm -r docs
/tmp/tfplugindocs
- name: Commit And Push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ `git status --porcelain` ]]; then
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name ${{ github.actor }}
git add .
git commit -m "added terraform docs"
git push
else
echo "no changes"
fi
terraform_lint:
name: Run terraform-lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Setup Terraform Lint
uses: terraform-linters/setup-tflint@v1
with:
tflint_version: v0.26.0
- name: Lint examples directory in a loop
run: |
tflint \
--config ${{ github.workspace }}/.tflint.hcl \
${{ github.workspace }}/examples/
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.5'
- name: Checkout code
uses: actions/checkout@v3
- name: Setup terraform CLI
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
terraform_wrapper: false
- name: Compile
run: make
- name: Run Unit Tests
run: make test
acc-tests:
runs-on: ubuntu-latest
## Skip acc tests on dependabot PRs because secrets are excluded on these PRs
## which in turn guarantees that the acc-tests will fail. We will rely solely on
## unit tests to tell us that the dependencies are working as expected.
if: ${{ github.actor != 'dependabot[bot]' }}
env:
LIGHTSTEP_API_KEY_PUBLIC: ${{ secrets.LIGHTSTEP_API_KEY_PUBLIC }}
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.5'
- name: Checkout code
uses: actions/checkout@v3
- name: Setup terraform CLI
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11
terraform_wrapper: false
- name: Compile
run: make
- name: Run Unit Tests
run: make acc-test
version_check:
name: Check version availability
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: false
- name: Check version availability
run: |
git fetch --tags
VERSION_TAG=$(cat .go-version)
if [ $(git tag -l "v$VERSION_TAG") ]; then
echo "Version tag v$VERSION_TAG already exists, please update .go-version with the version you intend to publish"
exit 1
else
echo "Version v$VERSION_TAG is available"
fi