diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3d983e6..f28cabb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,6 +11,8 @@ updates: open-pull-requests-limit: 5 labels: - dependencies + cooldown: + default-days: 7 - package-ecosystem: github-actions directory: / @@ -22,3 +24,5 @@ updates: open-pull-requests-limit: 5 labels: - dependencies + cooldown: + default-days: 7 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00a03d7..7562f0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,45 @@ concurrency: cancel-in-progress: true jobs: + changes: + name: Relevant changes + runs-on: ubuntu-latest + + outputs: + run: ${{ steps.filter.outputs.run }} + + steps: + - name: Checkout + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Detect relevant changes + id: filter + env: + EVENT_NAME: ${{ github.event_name }} + BEFORE_SHA: ${{ github.event.before }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + if [ "$EVENT_NAME" = "pull_request" ]; then + BASE="$BASE_SHA" + elif [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then + echo "run=true" >> "$GITHUB_OUTPUT" + exit 0 + else + BASE="$BEFORE_SHA" + fi + + if git diff --quiet "$BASE" "$GITHUB_SHA" -- \ + src tests config examples composer.json testo.php psalm.xml \ + rector.php .php-cs-fixer.php infection.json5 \ + .github/workflows/build.yml; then + echo "run=false" >> "$GITHUB_OUTPUT" + else + echo "run=true" >> "$GITHUB_OUTPUT" + fi + build: name: PHP ${{ matrix.php }} runs-on: ubuntu-latest @@ -55,6 +94,8 @@ jobs: prefer-lowest: name: Prefer lowest + needs: changes + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.run == 'true') }} runs-on: ubuntu-latest steps: @@ -86,6 +127,8 @@ jobs: coverage: name: Coverage & Mutation + needs: changes + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.run == 'true') }} runs-on: ubuntu-latest steps: @@ -120,6 +163,8 @@ jobs: compatibility: name: Backward compatibility + needs: changes + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.run == 'true') }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a920837..b889dbf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,8 +21,7 @@ jobs: name: Publish GitHub release runs-on: ubuntu-latest permissions: - # creating a Release object is a write to the repository - contents: write + contents: write # Needed to create the GitHub release steps: - name: Checkout diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index b5bc137..da30fad 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -14,8 +14,49 @@ concurrency: cancel-in-progress: true jobs: + changes: + name: Relevant changes + runs-on: ubuntu-latest + + outputs: + run: ${{ steps.filter.outputs.run }} + + steps: + - name: Checkout + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Detect relevant changes + id: filter + env: + EVENT_NAME: ${{ github.event_name }} + BEFORE_SHA: ${{ github.event.before }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + if [ "$EVENT_NAME" = "pull_request" ]; then + BASE="$BASE_SHA" + elif [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then + echo "run=true" >> "$GITHUB_OUTPUT" + exit 0 + else + BASE="$BEFORE_SHA" + fi + + if git diff --quiet "$BASE" "$GITHUB_SHA" -- \ + src tests config examples composer.json testo.php psalm.xml \ + rector.php .php-cs-fixer.php infection.json5 \ + .github/workflows/static-analysis.yml; then + echo "run=false" >> "$GITHUB_OUTPUT" + else + echo "run=true" >> "$GITHUB_OUTPUT" + fi + psalm: name: Psalm + needs: changes + if: ${{ !cancelled() && (needs.changes.result != 'success' || needs.changes.outputs.run == 'true') }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml new file mode 100644 index 0000000..f2bfb70 --- /dev/null +++ b/.github/workflows/zizmor.yml @@ -0,0 +1,38 @@ +name: GitHub Actions security + +on: + pull_request: + paths: &paths + - '.github/**/*.yml' + - '.github/**/*.yaml' + push: + branches: + - master + paths: *paths + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + zizmor: + name: zizmor + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + persist-credentials: false + + - name: Audit GitHub Actions + uses: zizmorcore/zizmor-action@3dc1ecc9bcb9e94e9b2c709687979e1298497054 # v0.6.2 + with: + advanced-security: false + annotations: true + online-audits: false + persona: auditor + version: 1.25.2