Use short -c option for sha512sum (#12602)
#674
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: Unit & Integration tests of Actions | |
| on: | |
| pull_request: | |
| paths: | |
| - '.github/**' | |
| push: | |
| branches: | |
| - "main" | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: docker://rhysd/actionlint:1.7.10 | |
| with: | |
| args: -color | |
| test-parse-comment: | |
| needs: | |
| - lint | |
| 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: strimzi/github-actions/.github/actions/dependencies/install-yq@main | |
| with: | |
| version: "v4.6.3" | |
| # Test all parse-comment scenarios | |
| - name: Test parse-comment action scenarios | |
| run: | | |
| set -e | |
| SCENARIOS_FILE=".github/tests/scenarios/parse-comment.yaml" | |
| WORKFLOW=".github/tests/workflows/parse-comment-template.yaml" | |
| echo "🧪 Running parse-comment 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 parse-comment scenarios passed!" | |
| test-generate-matrix: | |
| needs: | |
| - lint | |
| 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: strimzi/github-actions/.github/actions/dependencies/install-yq@main | |
| with: | |
| version: "v4.6.3" | |
| # Test all generate-matrix scenarios | |
| - name: Test generate-matrix action scenarios | |
| run: | | |
| set -e | |
| SCENARIOS_FILE=".github/tests/scenarios/generate-matrix.yaml" | |
| WORKFLOW=".github/tests/workflows/generate-matrix-template.yaml" | |
| echo "🧮 Running generate-matrix 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 | |
| # Run act with the scenario | |
| echo "▶️ Running test..." | |
| 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 $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 generate-matrix scenarios passed!" | |
| echo " Matrix generation logic validated ✅" | |
| test-validate-matrix: | |
| needs: | |
| - lint | |
| 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: strimzi/github-actions/.github/actions/dependencies/install-yq@main | |
| with: | |
| version: "v4.6.3" | |
| # Test all validate-matrix scenarios | |
| - name: Test validate-matrix action scenarios | |
| run: | | |
| set -e | |
| SCENARIOS_FILE=".github/tests/scenarios/validate-matrix.yaml" | |
| WORKFLOW=".github/tests/workflows/validate-matrix-template.yaml" | |
| echo "✅ Running validate-matrix 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") | |
| matrix_file=$(yq eval ".scenarios[$i].matrix_file" "$SCENARIOS_FILE") | |
| echo "───────────────────────────────────────" | |
| echo "🔍 Scenario $((i + 1))/$TOTAL: $id" | |
| echo " Description: $description" | |
| echo " Event: $event" | |
| echo " Matrix file: $matrix_file" | |
| # Load matrix content from file and compact to single line | |
| if [[ -f "$matrix_file" ]]; then | |
| TEST_MATRIX=$(jq -c . "$matrix_file") | |
| echo " ✅ Matrix loaded and compacted from file" | |
| else | |
| echo " ❌ Matrix file not found: $matrix_file" | |
| overall_result=false | |
| continue | |
| fi | |
| # Build environment variables from expectations | |
| env_args="--env TEST_MATRIX='$TEST_MATRIX'" | |
| # 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 | |
| # Run act with the scenario | |
| echo "▶️ Running test..." | |
| token_args="-s GITHUB_TOKEN=\"${{ secrets.GITHUB_TOKEN }}\"" | |
| if eval "act '$event' -W '$WORKFLOW' -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 --pull=false $env_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 validate-matrix scenarios passed!" | |
| echo " Matrix validation logic validated ✅" | |
| test-perf-report: | |
| needs: | |
| - lint | |
| 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: strimzi/github-actions/.github/actions/dependencies/install-yq@main | |
| with: | |
| version: "v4.6.3" | |
| # Test all perf-report scenarios | |
| - name: Test perf-report action scenarios | |
| run: | | |
| set -e | |
| SCENARIOS_FILE=".github/tests/scenarios/perf-report.yaml" | |
| WORKFLOW=".github/tests/workflows/perf-report-template.yaml" | |
| echo "📊 Running perf-report 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") | |
| perf_dir=$(yq eval ".scenarios[$i].inputs.performance_dir" "$SCENARIOS_FILE") | |
| expected_file=$(yq eval ".scenarios[$i].expectations.expected_output_file" "$SCENARIOS_FILE") | |
| expected_has_results=$(yq eval ".scenarios[$i].expectations.has_results" "$SCENARIOS_FILE") | |
| echo "───────────────────────────────────────" | |
| echo "🔍 Scenario $((i + 1))/$TOTAL: $id" | |
| echo " Description: $description" | |
| echo " Event: $event" | |
| echo " Performance dir: $perf_dir" | |
| # Create a temporary event file with the performance_dir input | |
| EVENT_FILE=$(mktemp) | |
| cat > "$EVENT_FILE" <<EOF | |
| { | |
| "inputs": { | |
| "performance_dir": "$perf_dir" | |
| } | |
| } | |
| EOF | |
| # Run act with the scenario | |
| # Mount docker socket into the container so nested act can work | |
| echo "▶️ Running test..." | |
| if act "$event" -W "$WORKFLOW" -e "$EVENT_FILE" \ | |
| -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04 \ | |
| --pull=false \ | |
| --env EXPECTED_OUTPUT_FILE="$expected_file" \ | |
| --env EXPECTED_HAS_RESULTS="$expected_has_results" \ | |
| -s GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}; then | |
| echo "✅ $id passed" | |
| else | |
| echo "❌ $id failed" | |
| overall_result=false | |
| fi | |
| # Clean up temporary event file | |
| rm "$EVENT_FILE" | |
| # 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 perf-report scenarios passed!" |