Skip to content

test workflow

test workflow #13

name: Test Module
on:
pull_request:
paths:
- '*.tf'
- 'tests/**'
- 'examples/terraform-test/**'
- '.github/workflows/terraform-test.yaml'
workflow_dispatch:
permissions:
contents: read
pull-requests: write
id-token: write
jobs:
test:
name: Run Terraform Tests
uses: oozou/.github/.github/workflows/terraform-test.yml@main
secrets: inherit
with:
aws_region: 'ap-southeast-1'
tf_version: '1.9.8'
go_version: '1.21'
test_example_path: 'examples/terraform-test'
timeout_minutes: 60
module_name: 'AWS ElastiCache'
iam_oidc_role: 'arn:aws:iam::562563527952:role/oozou-internal-devops-github-action-oidc-role' # oozou internal account
comment_on_failure:
name: Comment on PR if tests fail
runs-on: ubuntu-latest
needs: test
if: failure() && github.event_name == 'pull_request'
permissions:
pull-requests: write
steps:
- name: Report failed jobs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.CICD_GH_PAT }}
script: |
const run_id = process.env.GITHUB_RUN_ID;
const { data: jobs } = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id
});
const failedJobs = jobs.jobs
.filter(job => job.conclusion === 'failure')
.map(job => `- ${job.name} (Job ID: ${job.id})`)
.join('\n');
if (!failedJobs) {
core.info("No failed jobs found.");
return;
}
const prNumber = context.payload.pull_request?.number;
if (!prNumber) {
core.warning("Not a pull request context.");
return;
}
const commentBody = `@claude ### ❌ Failed Jobs in Workflow Run #${run_id}\n${failedJobs}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
core.info("Posted PR comment with failed jobs.");