chore: add instance_refresh, al2023 to github-runners #2374
Workflow file for this run
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: bats | |
on: | |
pull_request: | |
types: [labeled, opened, synchronize, unlabeled] | |
jobs: | |
bats: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.state == 'open' | |
container: cloudposse/test-harness:latest | |
env: | |
MAKE_INCLUDES: Makefile | |
TF_PLUGIN_CACHE_DIR: /tmp | |
BATS_MODULE_TESTS: input-descriptions lint output-descriptions provider-pinning | |
BATS_SUBMODULE_TESTS: input-descriptions lint output-descriptions | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Run tests on modified modules | |
id: get-modified-files | |
shell: bash -x -e -o pipefail {0} | |
env: | |
BASE_REF: ${{ github.base_ref }} | |
HEAD_REF: ${{ github.head_ref }} | |
run: | | |
# when running in test-harness, need to mark the directory safe for git operations | |
make git-safe-directory | |
MODIFIED_MODULES=($(git diff --name-only origin/${BASE_REF} origin/${HEAD_REF} | xargs -n 1 dirname | sort | uniq | grep ^modules/ || true)) | |
if [ -z "$MODIFIED_MODULES" ]; then | |
echo "No modules changed in this PR. Skipping tests." | |
exit 0 | |
else | |
echo "Running checks on the following modules:" | |
printf -- "- %s\n" "${MODIFIED_MODULES[@]#modules/}" | |
fi | |
pass=true | |
for dir in "${MODIFIED_MODULES[@]}"; do | |
printf "\n\nBegin testing in $dir\n" | |
( | |
status=pass | |
cd $dir | |
[[ $dir =~ modules/.*/modules/ ]] && tests=$BATS_SUBMODULE_TESTS || tests=$BATS_MODULE_TESTS | |
for test in $tests; do | |
printf "\n\nRunning ${test} in $dir\n" | |
bats -t /test/terraform/${test}.bats || status=fail | |
done | |
[[ $status == "pass" ]] | |
) || pass=false | |
printf "\n\nEnd of testing in $dir\n\n\n" | |
done | |
[[ $pass == "true" ]] |