name: valgrind

on:
  schedule:
    - cron: '0 23 * * WED' # Run every Wednesday at 23:00 (UTC)

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  valgrind:
    runs-on: [
      '@id:burn-linux-valgrind-${{ github.run_id }}-${{ github.run_attempt }}',
      '@image-family:ubuntu-2404-lts-amd64',
      '@image-project:ubuntu-os-cloud',
      '@disk-size:100',
      '@keep-alive:false',
      '@machine-type:n2-standard-16',
      '@os:linux',
      '@zones:northamerica-northeast1-b'
      ]
    steps:
      - name: checkout
        uses: actions/checkout@v6
      # --------------------------------------------------------------------------------
      - name: Install Mesa
        uses: tracel-ai/github-actions/install-mesa@v9
      # --------------------------------------------------------------------------------
      - name: Install valgrind
        run: |
          sudo apt-get install valgrind
      # --------------------------------------------------------------------------------
      - name: Run cargo-valgrind
        env:
          CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: "valgrind -s --leak-check=full --show-leak-kinds=all --error-exitcode=1"
        # Looking for vulnerabilities
        run: |
          cargo test
