Skip to content

feat: Add ACT CLI pytest wrapper for testing resolve-ci-vars action #105

feat: Add ACT CLI pytest wrapper for testing resolve-ci-vars action

feat: Add ACT CLI pytest wrapper for testing resolve-ci-vars action #105

Workflow file for this run

name: CI Test Action
on:
pull_request:
workflow_dispatch:
inputs:
pr:
description: 'PR number to test explicit PR input'
required: false
default: ''
permissions:
contents: read
issues: read
pull-requests: read
jobs:
test-resolve-vars:
name: Test Resolve Vars Action
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Variable Resolution
id: vars
uses: ./
with:
log_outputs: true
pr: ${{ github.event.inputs.pr }}
static_inputs: |
username=testuser
environment=development
# Jinja2 inputs to evaluate:
# These are intentionally nonsensical, but they demonstrate the syntax
# and they test the tool's ability to evaluate dynamic jinja2 expressions.
jinja_inputs: |
greeting='Hello, ' + 'World!'
is_prod=False
computed_name='${{ 'testuser' }}' + '_' + '${{ 'development' }}'
port_number=8080 if 'true' == 'false' else 443
answer=42
- name: Print outputs
run: |
echo "=== DEBUG: Raw output ==="
echo "steps.vars.outputs.custom: '${{ steps.vars.outputs.custom }}'"
echo "=========================="
- name: Verify custom outputs
run: |
# Check static variables
if [ "${{ fromJSON(steps.vars.outputs.custom).username }}" != "testuser" ]; then
echo "ERROR: username output doesn't match expected value"
exit 1
fi
if [ "${{ fromJSON(steps.vars.outputs.custom).environment }}" != "development" ]; then
echo "ERROR: environment output doesn't match expected value"
exit 1
fi
# Check jinja variables
if [ "${{ fromJSON(steps.vars.outputs.custom).greeting }}" != "Hello, World!" ]; then
echo "ERROR: greeting output doesn't match expected value"
echo "Expected: Hello, World!"
echo "Actual: ${{ fromJSON(steps.vars.outputs.custom).greeting }}"
exit 1
fi
if [ "${{ fromJSON(steps.vars.outputs.custom).is_prod }}" != "False" ]; then
echo "ERROR: is_prod output doesn't match expected value"
echo "Expected: False"
echo "Actual: ${{ fromJSON(steps.vars.outputs.custom).is_prod }}"
exit 1
fi
if [ "${{ fromJSON(steps.vars.outputs.custom).computed_name }}" != "testuser_development" ]; then
echo "ERROR: computed_name output doesn't match expected value"
echo "Expected: testuser_development"
echo "Actual: ${{ fromJSON(steps.vars.outputs.custom).computed_name }}"
exit 1
fi
if [ "${{ fromJSON(steps.vars.outputs.custom).port_number }}" != "443" ]; then
echo "ERROR: port_number output doesn't match expected value"
echo "Expected: 443"
echo "Actual: ${{ fromJSON(steps.vars.outputs.custom).port_number }}"
exit 1
fi
if [ "${{ fromJSON(steps.vars.outputs.custom).answer }}" != "42" ]; then
echo "ERROR: answer output doesn't match expected value"
echo "Expected: 42"
echo "Actual: ${{ fromJSON(steps.vars.outputs.custom).answer }}"
exit 1
fi
echo "✅ All tests passed!"
echo "Static outputs:"
echo " username: ${{ fromJSON(steps.vars.outputs.custom).username }}"
echo " environment: ${{ fromJSON(steps.vars.outputs.custom).environment }}"
echo "Jinja outputs:"
echo " greeting: ${{ fromJSON(steps.vars.outputs.custom).greeting }}"
echo " is_prod: ${{ fromJSON(steps.vars.outputs.custom).is_prod }}"
echo " computed_name: ${{ fromJSON(steps.vars.outputs.custom).computed_name }}"
echo " port_number: ${{ fromJSON(steps.vars.outputs.custom).port_number }}"
- name: Print CI variables output
run: |
echo "=== DEBUG: Standard CI Variables ==="
echo "All variables: ${{ steps.vars.outputs.custom }}"
echo "Resolved repo: ${{ steps.vars.outputs.resolved-repo-name-full }}"
echo "Resolved branch: ${{ steps.vars.outputs.resolved-git-branch }}"
echo "PR number: ${{ steps.vars.outputs.pr-number }}"
echo "Run ID: ${{ steps.vars.outputs.run-id }}"
echo "Is PR: ${{ steps.vars.outputs.is-pr }}"
echo "=================================="
- name: Verify standard CI variables
run: |
# Check that standard CI variables are populated
if [ -z "${{ steps.vars.outputs.resolved-repo-name-full }}" ]; then
echo "ERROR: resolved-repo-name-full variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.resolved-git-branch }}" ]; then
echo "ERROR: resolved-git-branch variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.resolved-repo-owner }}" ]; then
echo "ERROR: resolved-repo-owner variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.resolved-repo-name }}" ]; then
echo "ERROR: resolved-repo-name variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.run-id }}" ]; then
echo "ERROR: run-id variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.is-pr }}" ]; then
echo "ERROR: is-pr variable should be populated"
exit 1
fi
# Verify resolved-repo-name-full matches expected format
if [ "${{ steps.vars.outputs.resolved-repo-name-full }}" != "aaronsteers/resolve-ci-vars-action" ]; then
echo "ERROR: resolved-repo-name-full should be aaronsteers/resolve-ci-vars-action"
echo "Actual: ${{ steps.vars.outputs.resolved-repo-name-full }}"
exit 1
fi
# Verify resolved-repo-owner matches expected value
if [ "${{ steps.vars.outputs.resolved-repo-owner }}" != "aaronsteers" ]; then
echo "ERROR: resolved-repo-owner should be aaronsteers"
echo "Actual: ${{ steps.vars.outputs.resolved-repo-owner }}"
exit 1
fi
# Verify resolved-repo-name matches expected value
if [ "${{ steps.vars.outputs.resolved-repo-name }}" != "resolve-ci-vars-action" ]; then
echo "ERROR: resolved-repo-name should be resolve-ci-vars-action"
echo "Actual: ${{ steps.vars.outputs.resolved-repo-name }}"
exit 1
fi
# Verify is-pr is false for non-PR events (this test runs on pull_request so should be true)
if [ "${{ steps.vars.outputs.is-pr }}" != "true" ]; then
echo "ERROR: is-pr should be true for pull_request events"
echo "Actual: ${{ steps.vars.outputs.is-pr }}"
exit 1
fi
echo "✅ Standard CI variables test passed!"
- name: Verify standard CI variables
run: |
# Check that standard CI variables are populated
if [ -z "${{ steps.vars.outputs.resolved-repo-name-full }}" ]; then
echo "ERROR: resolved-repo-name-full variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.resolved-git-branch }}" ]; then
echo "ERROR: resolved-git-branch variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.resolved-repo-owner }}" ]; then
echo "ERROR: resolved-repo-owner variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.resolved-repo-name }}" ]; then
echo "ERROR: resolved-repo-name variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.run-id }}" ]; then
echo "ERROR: run-id variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars.outputs.is-pr }}" ]; then
echo "ERROR: is-pr variable should be populated"
exit 1
fi
# Verify resolved-repo-name-full matches expected format
if [ "${{ steps.vars.outputs.resolved-repo-name-full }}" != "aaronsteers/resolve-ci-vars-action" ]; then
echo "ERROR: resolved-repo-name-full should be aaronsteers/resolve-ci-vars-action"
echo "Actual: ${{ steps.vars.outputs.resolved-repo-name-full }}"
exit 1
fi
# Verify resolved-repo-owner matches expected value
if [ "${{ steps.vars.outputs.resolved-repo-owner }}" != "aaronsteers" ]; then
echo "ERROR: resolved-repo-owner should be aaronsteers"
echo "Actual: ${{ steps.vars.outputs.resolved-repo-owner }}"
exit 1
fi
# Verify resolved-repo-name matches expected value
if [ "${{ steps.vars.outputs.resolved-repo-name }}" != "resolve-ci-vars-action" ]; then
echo "ERROR: resolved-repo-name should be resolve-ci-vars-action"
echo "Actual: ${{ steps.vars.outputs.resolved-repo-name }}"
exit 1
fi
# Verify is-pr is false for non-PR events (this test runs on pull_request so should be true)
if [ "${{ steps.vars.outputs.is-pr }}" != "true" ]; then
echo "ERROR: is-pr should be true for pull_request events"
echo "Actual: ${{ steps.vars.outputs.is-pr }}"
exit 1
fi
echo "✅ Standard CI variables test passed!"
- name: Run Variable Resolution (Explicit PR 5)
id: vars-pr5
uses: ./
with:
pr: 5
log_outputs: true
static_inputs: |
username=testuser
environment=development
# Jinja2 inputs to evaluate:
# These are intentionally nonsensical, but they demonstrate the syntax
# and they test the tool's ability to evaluate dynamic jinja2 expressions.
jinja_inputs: |
greeting='Hello, ' + 'World!'
is_prod=False
computed_name='${{ 'testuser' }}' + '_' + '${{ 'development' }}'
port_number=8080 if 'true' == 'false' else 443
answer=42
- name: Verify standard CI variables (explicit PR)
run: |
# Check that standard CI variables are populated
if [ "${{ steps.vars-pr5.outputs.pr-number }}" != "5" ]; then
echo "ERROR: pr-number should be 5, not '${{ steps.vars-pr5.outputs.pr-number }}'"
exit 1
fi
if [ -z "${{ steps.vars-pr5.outputs.resolved-repo-name-full }}" ]; then
echo "ERROR: resolved-repo-name-full variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars-pr5.outputs.resolved-git-branch }}" ]; then
echo "ERROR: resolved-git-branch variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars-pr5.outputs.resolved-repo-owner }}" ]; then
echo "ERROR: resolved-repo-owner variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars-pr5.outputs.resolved-repo-name }}" ]; then
echo "ERROR: resolved-repo-name variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars-pr5.outputs.run-id }}" ]; then
echo "ERROR: run-id variable should be populated"
exit 1
fi
if [ -z "${{ steps.vars-pr5.outputs.is-pr }}" ]; then
echo "ERROR: is-pr variable should be populated"
exit 1
fi
# Verify resolved-repo-name-full matches expected format
if [ "${{ steps.vars-pr5.outputs.resolved-repo-name-full }}" != "aaronsteers/resolve-ci-vars-action" ]; then
echo "ERROR: resolved-repo-name-full should be aaronsteers/resolve-ci-vars-action"
echo "Actual: ${{ steps.vars-pr5.outputs.resolved-repo-name-full }}"
exit 1
fi
# Verify resolved-repo-owner matches expected value
if [ "${{ steps.vars-pr5.outputs.resolved-repo-owner }}" != "aaronsteers" ]; then
echo "ERROR: resolved-repo-owner should be aaronsteers"
echo "Actual: ${{ steps.vars-pr5.outputs.resolved-repo-owner }}"
exit 1
fi
# Verify resolved-repo-name matches expected value
if [ "${{ steps.vars-pr5.outputs.resolved-repo-name }}" != "resolve-ci-vars-action" ]; then
echo "ERROR: resolved-repo-name should be resolve-ci-vars-action"
echo "Actual: ${{ steps.vars-pr5.outputs.resolved-repo-name }}"
exit 1
fi
# Verify is-pr is false for non-PR events (this test runs on pull_request so should be true)
if [ "${{ steps.vars-pr5.outputs.is-pr }}" != "true" ]; then
echo "ERROR: is-pr should be true for pull_request events"
echo "Actual: ${{ steps.vars-pr5.outputs.is-pr }}"
exit 1
fi
echo "✅ Standard CI variables test passed!"