Skip to content

Commit

Permalink
Update test.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
shayki5 authored Jul 23, 2024
1 parent bdc6d19 commit 2c309ba
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,63 @@ on:
type: number

jobs:
test-inputs:
test-push-pull-request:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Run action (inputs only)
- name: Run action (no inputs expected)
uses: ./
id: print_inputs
- name: Check output (inputs only)
- name: Check output (no inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"No workflow_dispatch inputs found in the event payload."* ]]; then
echo "Test passed: No inputs were found, as expected for push/pull_request events"
else
echo "Test failed: Unexpected output for push/pull_request events"
exit 1
fi
test-workflow-dispatch:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Run action (inputs expected)
uses: ./
id: print_inputs
- name: Check output (inputs expected)
run: |
echo "Action output:"
echo "${{ steps.print_inputs.outputs.output }}"
if [[ "${{ steps.print_inputs.outputs.output }}" == *"test_name"* && "${{ steps.print_inputs.outputs.output }}" == *"test_number"* ]]; then
echo "Test passed: Inputs were printed correctly"
echo "Test passed: Inputs were printed correctly for workflow_dispatch event"
else
echo "Test failed: Inputs were not printed as expected"
echo "Expected to find 'test_name' and 'test_number' in the output"
echo "Test failed: Inputs were not printed as expected for workflow_dispatch event"
exit 1
fi
test-inputs-and-env:
test-env-vars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run action (inputs and env vars)
- name: Run action (with env vars)
uses: ./
id: print_inputs_and_env
with:
print_env_vars: 'true'
- name: Check output (inputs and env vars)
- name: Check output (env vars)
run: |
echo "Action output:"
echo "${{ steps.print_inputs_and_env.outputs.output }}"
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"test_name"* &&
"${{ steps.print_inputs_and_env.outputs.output }}" == *"test_number"* &&
"${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* ]]; then
echo "Test passed: Inputs and env vars were printed correctly"
if [[ "${{ steps.print_inputs_and_env.outputs.output }}" == *"Printing environment variables:"* && "${{ steps.print_inputs_and_env.outputs.output }}" == *"GITHUB_"* ]]; then
echo "Test passed: Environment variables were printed correctly"
else
echo "Test failed: Inputs or env vars were not printed as expected"
echo "Expected to find 'test_name', 'test_number', and 'Printing environment variables:' in the output"
echo "Test failed: Environment variables were not printed as expected"
exit 1
fi

0 comments on commit 2c309ba

Please sign in to comment.