Skip second build for CO repo and properly set helm and maven package… #18
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: Test Utils Actions | |
| on: | |
| pull_request: | |
| branches: | |
| - "*" | |
| push: | |
| branches: | |
| - "main" | |
| - "release-*" | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-check-permissions: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # Install dependencies | |
| - name: Install act | |
| run: | | |
| # Install act for workflow testing | |
| curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash | |
| sudo install -m 0755 ./bin/act /usr/local/bin/act | |
| - name: Install yq | |
| uses: ./.github/actions/dependencies/install-yq | |
| with: | |
| version: "v4.6.3" | |
| # Test all check-permissions scenarios | |
| - name: Test check-permissions action scenarios | |
| run: | | |
| set -e | |
| SCENARIOS_FILE=".github/tests/scenarios/check-permissions.yaml" | |
| WORKFLOW=".github/tests/workflows/check-permissions-template.yaml" | |
| echo "🔐 Running check-permissions action tests..." | |
| echo "📁 Loading scenarios from: $SCENARIOS_FILE" | |
| # Get total number of scenarios | |
| TOTAL=$(yq eval '.scenarios | length' "$SCENARIOS_FILE") | |
| echo "📊 Found $TOTAL test scenarios" | |
| echo | |
| echo "⚠️ Note: These tests validate action structure and input handling." | |
| echo " GitHub API permission checks depend on actual repository permissions." | |
| echo | |
| # Initialize overall result tracker | |
| overall_result=true | |
| # Loop through each scenario | |
| for i in $(seq 0 $((TOTAL - 1))); do | |
| # Extract scenario details using yq | |
| id=$(yq eval ".scenarios[$i].id" "$SCENARIOS_FILE") | |
| description=$(yq eval ".scenarios[$i].description" "$SCENARIOS_FILE") | |
| event=$(yq eval ".scenarios[$i].event" "$SCENARIOS_FILE") | |
| fixture=$(yq eval ".scenarios[$i].fixture" "$SCENARIOS_FILE") | |
| echo "───────────────────────────────────────" | |
| echo "🔍 Scenario $((i + 1))/$TOTAL: $id" | |
| echo " Description: $description" | |
| echo " Event: $event" | |
| echo " Fixture: $fixture" | |
| # Build environment variables from expectations | |
| env_args="" | |
| # Get all expectation keys and build env vars | |
| expectation_keys=$(yq eval ".scenarios[$i].expectations | keys | .[]" "$SCENARIOS_FILE") | |
| for key in $expectation_keys; do | |
| value=$(yq eval ".scenarios[$i].expectations.$key" "$SCENARIOS_FILE") | |
| env_key="EXPECT_$(echo "$key" | tr '[:lower:]' '[:upper:]')" | |
| env_args="$env_args --env $env_key=\"$value\"" | |
| done | |
| # Extract actor from event fixture for proper GITHUB_ACTOR override | |
| actor=$(yq eval '.actor' "$fixture") | |
| echo " 👤 Actor from fixture: $actor" | |
| # Run act with the scenario | |
| echo "▶️ Running test..." | |
| # Override GITHUB_ACTOR to match the actor in the event fixture | |
| actor_args="--env GITHUB_ACTOR=\"$actor\"" | |
| token_args="-s GITHUB_TOKEN=\"${{ secrets.GITHUB_TOKEN }}\"" | |
| if eval "act '$event' -W '$WORKFLOW' -e '$fixture' -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false $env_args $actor_args $token_args"; then | |
| echo "✅ $id completed" | |
| else | |
| echo "❌ $id failed" | |
| overall_result=false | |
| fi | |
| # Print blank line for better readability | |
| echo | |
| done | |
| if [ "$overall_result" = "false" ]; then | |
| echo "There are some test ❌. Please check the logs for more details." | |
| exit 1 | |
| fi | |
| echo "───────────────────────────────────────" | |
| echo "🎉 All $TOTAL check-permissions scenarios completed!" | |
| echo " Action structure and input handling validated ✅" | |
| test-should-run: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # Install dependencies | |
| - name: Install act | |
| run: | | |
| # Install act for workflow testing | |
| curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash | |
| sudo install -m 0755 ./bin/act /usr/local/bin/act | |
| - name: Install yq | |
| uses: ./.github/actions/dependencies/install-yq | |
| with: | |
| version: "v4.6.3" | |
| # Test all should-run scenarios | |
| - name: Test should-run action scenarios | |
| run: | | |
| set -e | |
| SCENARIOS_FILE=".github/tests/scenarios/should-run.yaml" | |
| WORKFLOW=".github/tests/workflows/should-run-template.yaml" | |
| echo "🚦 Running should-run action tests..." | |
| echo "📁 Loading scenarios from: $SCENARIOS_FILE" | |
| # Get total number of scenarios | |
| TOTAL=$(yq eval '.scenarios | length' "$SCENARIOS_FILE") | |
| echo "📊 Found $TOTAL test scenarios" | |
| echo | |
| # Initialize overall result tracker | |
| overall_result=true | |
| # Loop through each scenario | |
| for i in $(seq 0 $((TOTAL - 1))); do | |
| # Extract scenario details using yq | |
| id=$(yq eval ".scenarios[$i].id" "$SCENARIOS_FILE") | |
| description=$(yq eval ".scenarios[$i].description" "$SCENARIOS_FILE") | |
| event=$(yq eval ".scenarios[$i].event" "$SCENARIOS_FILE") | |
| fixture=$(yq eval ".scenarios[$i].fixture" "$SCENARIOS_FILE") | |
| echo "───────────────────────────────────────" | |
| echo "🔍 Scenario $((i + 1))/$TOTAL: $id" | |
| echo " Description: $description" | |
| echo " Event: $event" | |
| echo " Fixture: $fixture" | |
| # Build environment variables from expectations | |
| env_args="" | |
| # Get all expectation keys and build env vars | |
| expectation_keys=$(yq eval ".scenarios[$i].expectations | keys | .[]" "$SCENARIOS_FILE") | |
| for key in $expectation_keys; do | |
| value=$(yq eval ".scenarios[$i].expectations.$key" "$SCENARIOS_FILE") | |
| env_key="EXPECT_$(echo "$key" | tr '[:lower:]' '[:upper:]')" | |
| env_args="$env_args --env $env_key=\"$value\"" | |
| done | |
| token_args="-s GITHUB_TOKEN=\"${{ secrets.GITHUB_TOKEN }}\"" | |
| # Run act with the scenario | |
| echo "▶️ Running test..." | |
| if eval "act '$event' -W '$WORKFLOW' -e '$fixture' -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false $env_args $token_args"; then | |
| echo "✅ $id passed" | |
| else | |
| echo "❌ $id failed" | |
| overall_result=false | |
| fi | |
| # Print blank line for better readability | |
| echo | |
| done | |
| if [ "$overall_result" = "false" ]; then | |
| echo "There are some test ❌. Please check the logs for more details." | |
| exit 1 | |
| fi | |
| echo "───────────────────────────────────────" | |
| echo "🎉 All $TOTAL should-run scenarios passed!" |