feat: Add automatic standard CI variable resolution #71
Workflow file for this run
This file contains hidden or 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: CI Test Action | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
test-resolve-vars: | |
name: Test Resolve Vars Action | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Test resolve vars action | |
id: test-vars | |
uses: ./ | |
with: | |
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: Print outputs | |
run: | | |
echo "=== DEBUG: Raw output ===" | |
echo "steps.test-vars.outputs.all: '${{ steps.test-vars.outputs.all }}'" | |
echo "==========================" | |
- name: Verify outputs | |
run: | | |
# Check static variables | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).username }}" != "testuser" ]; then | |
echo "ERROR: username output doesn't match expected value" | |
exit 1 | |
fi | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).environment }}" != "development" ]; then | |
echo "ERROR: environment output doesn't match expected value" | |
exit 1 | |
fi | |
# Check jinja variables | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).greeting }}" != "Hello, World!" ]; then | |
echo "ERROR: greeting output doesn't match expected value" | |
echo "Expected: Hello, World!" | |
echo "Actual: ${{ fromJSON(steps.test-vars.outputs.all).greeting }}" | |
exit 1 | |
fi | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).is_prod }}" != "False" ]; then | |
echo "ERROR: is_prod output doesn't match expected value" | |
echo "Expected: False" | |
echo "Actual: ${{ fromJSON(steps.test-vars.outputs.all).is_prod }}" | |
exit 1 | |
fi | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).computed_name }}" != "testuser_development" ]; then | |
echo "ERROR: computed_name output doesn't match expected value" | |
echo "Expected: testuser_development" | |
echo "Actual: ${{ fromJSON(steps.test-vars.outputs.all).computed_name }}" | |
exit 1 | |
fi | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).port_number }}" != "443" ]; then | |
echo "ERROR: port_number output doesn't match expected value" | |
echo "Expected: 443" | |
echo "Actual: ${{ fromJSON(steps.test-vars.outputs.all).port_number }}" | |
exit 1 | |
fi | |
if [ "${{ fromJSON(steps.test-vars.outputs.all).answer }}" != "42" ]; then | |
echo "ERROR: answer output doesn't match expected value" | |
echo "Expected: 42" | |
echo "Actual: ${{ fromJSON(steps.test-vars.outputs.all).answer }}" | |
exit 1 | |
fi | |
echo "✅ All tests passed!" | |
echo "Static outputs:" | |
echo " username: ${{ fromJSON(steps.test-vars.outputs.all).username }}" | |
echo " environment: ${{ fromJSON(steps.test-vars.outputs.all).environment }}" | |
echo "Jinja outputs:" | |
echo " greeting: ${{ fromJSON(steps.test-vars.outputs.all).greeting }}" | |
echo " is_prod: ${{ fromJSON(steps.test-vars.outputs.all).is_prod }}" | |
echo " computed_name: ${{ fromJSON(steps.test-vars.outputs.all).computed_name }}" | |
echo " port_number: ${{ fromJSON(steps.test-vars.outputs.all).port_number }}" | |
test-standard-ci-vars: | |
name: Test Standard CI Variables | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Test standard CI vars enabled | |
id: test-ci-vars | |
uses: ./ | |
with: | |
log_outputs: true | |
static_inputs: | | |
custom_var=test_value | |
- name: Print CI variables output | |
run: | | |
echo "=== DEBUG: Standard CI Variables ===" | |
echo "All variables: ${{ steps.test-ci-vars.outputs.all }}" | |
echo "Target repo: ${{ steps.test-ci-vars.outputs.repo }}" | |
echo "Trigger type: ${{ steps.test-ci-vars.outputs.trigger-type }}" | |
echo "Actor: ${{ steps.test-ci-vars.outputs.actor }}" | |
echo "Repo owner: ${{ steps.test-ci-vars.outputs.repo-owner }}" | |
echo "Repository name: ${{ steps.test-ci-vars.outputs.repo-name }}" | |
echo "Repository name full: ${{ steps.test-ci-vars.outputs.repo-name-full }}" | |
echo "Restricted security mode: ${{ steps.test-ci-vars.outputs.restricted-security-mode }}" | |
echo "==================================" | |
- name: Verify standard CI variables | |
run: | | |
# Check that standard CI variables are populated | |
if [ -z "${{ steps.test-ci-vars.outputs.repo }}" ]; then | |
echo "ERROR: repo variable should be populated" | |
exit 1 | |
fi | |
if [ -z "${{ steps.test-ci-vars.outputs.trigger-type }}" ]; then | |
echo "ERROR: trigger-type variable should be populated" | |
exit 1 | |
fi | |
if [ -z "${{ steps.test-ci-vars.outputs.actor }}" ]; then | |
echo "ERROR: actor variable should be populated" | |
exit 1 | |
fi | |
if [ -z "${{ steps.test-ci-vars.outputs.repo-owner }}" ]; then | |
echo "ERROR: repo-owner variable should be populated" | |
exit 1 | |
fi | |
if [ -z "${{ steps.test-ci-vars.outputs.repo-name }}" ]; then | |
echo "ERROR: repo-name variable should be populated" | |
exit 1 | |
fi | |
if [ -z "${{ steps.test-ci-vars.outputs.repo-name-full }}" ]; then | |
echo "ERROR: repo-name-full variable should be populated" | |
exit 1 | |
fi | |
if [ -z "${{ steps.test-ci-vars.outputs.restricted-security-mode }}" ]; then | |
echo "ERROR: restricted-security-mode variable should be populated" | |
exit 1 | |
fi | |
# Verify repo matches expected format | |
if [ "${{ steps.test-ci-vars.outputs.repo }}" != "aaronsteers/resolve-vars-action" ]; then | |
echo "ERROR: repo should be aaronsteers/resolve-vars-action" | |
echo "Actual: ${{ steps.test-ci-vars.outputs.repo }}" | |
exit 1 | |
fi | |
# Verify repo-owner matches expected value | |
if [ "${{ steps.test-ci-vars.outputs.repo-owner }}" != "aaronsteers" ]; then | |
echo "ERROR: repo-owner should be aaronsteers" | |
echo "Actual: ${{ steps.test-ci-vars.outputs.repo-owner }}" | |
exit 1 | |
fi | |
# Verify repo-name matches expected value | |
if [ "${{ steps.test-ci-vars.outputs.repo-name }}" != "resolve-vars-action" ]; then | |
echo "ERROR: repo-name should be resolve-vars-action" | |
echo "Actual: ${{ steps.test-ci-vars.outputs.repo-name }}" | |
exit 1 | |
fi | |
# Verify repo-name-full matches expected value | |
if [ "${{ steps.test-ci-vars.outputs.repo-name-full }}" != "aaronsteers/resolve-vars-action" ]; then | |
echo "ERROR: repo-name-full should be aaronsteers/resolve-vars-action" | |
echo "Actual: ${{ steps.test-ci-vars.outputs.repo-name-full }}" | |
exit 1 | |
fi | |
# Verify restricted-security-mode is false for non-fork PRs | |
if [ "${{ steps.test-ci-vars.outputs.restricted-security-mode }}" != "false" ]; then | |
echo "ERROR: restricted-security-mode should be false for non-fork PRs" | |
echo "Actual: ${{ steps.test-ci-vars.outputs.restricted-security-mode }}" | |
exit 1 | |
fi | |
# Check that custom variables are still included | |
if [ "${{ fromJSON(steps.test-ci-vars.outputs.all).custom_var }}" != "test_value" ]; then | |
echo "ERROR: custom_var should still be included with standard CI vars" | |
exit 1 | |
fi | |
echo "✅ Standard CI variables test passed!" | |
- name: Test with standard CI vars disabled | |
id: test-no-ci-vars | |
uses: ./ | |
with: | |
standard_ci_vars: false | |
static_inputs: | | |
test_var=backward_compat | |
- name: Verify standard CI vars disabled | |
run: | | |
# Ensure CI variables are NOT populated when disabled | |
if [ -n "${{ steps.test-no-ci-vars.outputs.repo }}" ]; then | |
echo "ERROR: repo should not be populated when standard_ci_vars is false" | |
exit 1 | |
fi | |
# Ensure custom variables still work | |
if [ "${{ fromJSON(steps.test-no-ci-vars.outputs.all).test_var }}" != "backward_compat" ]; then | |
echo "ERROR: custom variables should still work when standard_ci_vars is false" | |
exit 1 | |
fi | |
echo "✅ Standard CI vars disabled test passed!" |