From 04ec9fe285985e7f031042bef6d05cf35a2fefdd Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Tue, 24 Jun 2025 14:10:37 -0400 Subject: [PATCH] fix: check reqs --- .github/workflows/main.yml | 112 ++++++++++++++++++++++++++++++++++--- action.yml | 20 +++++++ 2 files changed, 125 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 695b508..381e9b9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,11 +14,12 @@ jobs: - name: Checkout uses: actions/checkout@v4.2.2 with: - submodules: 'true' + submodules: "true" - name: Install dependencies run: pip install -r src/scripts/app/requirements.txt - name: Run tests and collect coverage run: pytest src/scripts/app/ --cov + - name: Upload coverage to Codecov (script) uses: ./ with: @@ -55,7 +56,7 @@ jobs: - name: Checkout uses: actions/checkout@v4.2.2 with: - submodules: 'true' + submodules: "true" - name: Install dependencies run: pip install -r src/scripts/app/requirements.txt - name: Run tests and collect coverage @@ -104,15 +105,16 @@ jobs: - name: Checkout uses: actions/checkout@v4.2.2 with: - submodules: 'true' + submodules: "true" - name: Install deps run: | - apt-get install git + apt-get update && apt-get install -y git + - name: Upload coverage to Codecov (script) uses: ./ with: files: ./coverage/script/coverage-final.json - flags: script-${{ matrix.os }} + flags: script-container name: codecov-script verbose: true token: ${{ secrets.CODECOV_TOKEN }} @@ -120,7 +122,7 @@ jobs: uses: ./ with: files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json - flags: demo-${{ matrix.os }} + flags: demo-container name: codecov-demo verbose: true token: ${{ secrets.CODECOV_TOKEN }} @@ -128,8 +130,104 @@ jobs: uses: ./ with: files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json - flags: version-${{ matrix.os }} + flags: version-container name: codecov-version version: v9.1.0 verbose: true token: ${{ secrets.CODECOV_TOKEN }} + + run-alpine-missing-deps: + runs-on: ubuntu-latest + container: alpine:latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + with: + submodules: "true" + - name: Upload coverage to Codecov (should fail due to missing dependencies) + id: codecov-upload + continue-on-error: true + uses: ./ + with: + files: ./coverage/script/coverage-final.json + flags: script-alpine-missing-deps + name: codecov-script + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Verify dependency check failed + run: | + if [ "${{ steps.codecov-upload.outcome }}" = "failure" ]; then + echo "✓ Action correctly failed due to missing dependencies" + exit 0 + else + echo "✗ Action should have failed but didn't" + exit 1 + fi + + run-alpine-success: + runs-on: ubuntu-latest + container: alpine:latest + steps: + - name: Install all required deps + run: | + apk add git curl gnupg bash + - name: Checkout + uses: actions/checkout@v4.2.2 + with: + submodules: "true" + - name: Upload coverage to Codecov (should succeed) + uses: ./ + with: + files: ./coverage/script/coverage-final.json + flags: script-alpine-success + name: codecov-script + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage to Codecov (demo) + uses: ./ + with: + files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json + flags: demo-alpine-success + name: codecov-demo + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage to Codecov (version) + uses: ./ + with: + files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json,./coverage/coverage-final.json + flags: version-alpine-success + name: codecov-version + version: v9.1.0 + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + + run-alpine-partial-deps: + runs-on: ubuntu-latest + container: alpine:latest + steps: + - name: Install only some deps (missing gpg and bash) + run: | + apk add git curl + - name: Checkout + uses: actions/checkout@v4.2.2 + with: + submodules: "true" + - name: Upload coverage to Codecov (should fail due to missing gpg and bash) + id: codecov-upload + continue-on-error: true + uses: ./ + with: + files: ./coverage/script/coverage-final.json + flags: script-alpine-partial-deps + name: codecov-script + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Verify dependency check failed + run: | + if [ "${{ steps.codecov-upload.outcome }}" = "failure" ]; then + echo "✓ Action correctly failed due to missing dependencies (gpg and bash)" + exit 0 + else + echo "✗ Action should have failed but didn't" + exit 1 + fi diff --git a/action.yml b/action.yml index f99bba6..375b8b0 100644 --- a/action.yml +++ b/action.yml @@ -175,6 +175,26 @@ branding: runs: using: "composite" steps: + - name: Check system dependencies + shell: sh + run: | + missing_deps="" + + # Check for required commands + for cmd in bash git curl gpg; do + if ! command -v "$cmd" >/dev/null 2>&1; then + missing_deps="$missing_deps $cmd" + fi + done + + # Report missing required dependencies + if [ -n "$missing_deps" ]; then + echo "Error: The following required dependencies are missing:$missing_deps" + echo "Please install these dependencies before using this action." + exit 1 + fi + + echo "All required system dependencies are available." - name: Action version shell: bash run: |