name: Continuous Integration
on:
  push:
    branches: [main]

jobs:
  snap:
    permissions:
      contents: read
    uses: ./.github/workflows/snap.yml
    with:
      deploy: true
    secrets: inherit

  matrix:
    uses: ./.github/workflows/matrix.yml
    with:
      publish: false
    secrets: inherit

  fuzzing:
    permissions:
      actions: read # to fetch the artifacts (google/oss-fuzz/infra/cifuzz/actions/run_fuzzers)
      contents: read # to clone the repo (google/oss-fuzz/infra/cifuzz/actions/run_fuzzers)

    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - name: Build Fuzzers
        id: build
        uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@32f1d4deadc82279ec9001a837f2424e185c69a2 # master
        with:
          oss-fuzz-project-name: "fwupd"
          dry-run: false
      - name: Run Fuzzers
        uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@32f1d4deadc82279ec9001a837f2424e185c69a2 # master
        with:
          oss-fuzz-project-name: "fwupd"
          fuzz-seconds: 150
          dry-run: false
      - name: Upload Crash
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        if: failure() && steps.build.outcome == 'success'
        with:
          name: artifacts
          path: ./out/artifacts
