name: Coverage

# Run weekly on Sunday at midnight (UTC).
on:
  schedule:
    - cron: "0 0 * * 0"

permissions:
  contents: read

jobs:
  go:
    name: Go
    timeout-minutes: 30
    runs-on: ${{ vars.LINKERD2_RUNNER || 'ubuntu-24.04' }}
    container:
      image: golang:1.24
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      - run: go install gotest.tools/gotestsum@v0.4.2
      - run: gotestsum -- -cover -coverprofile=coverage.out -v -mod=readonly ./...
      - uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
        with:
          files: ./coverage.out
          flags: unittests,golang

  js:
    name: JS
    timeout-minutes: 30
    runs-on: ${{ vars.LINKERD2_RUNNER || 'ubuntu-24.04' }}
    container:
      image: node:20-stretch
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      - name: Yarn setup
        shell: bash
        run: bin/scurl -o- https://yarnpkg.com/install.sh | bash -s -- --version 1.21.1 --network-concurrency 1
      - name: Unit tests
        run: |
          export PATH="$HOME/.yarn/bin:$PATH"
          export NODE_ENV=test
          bin/web --frozen-lockfile
          bin/web test --reporters="jest-progress-bar-reporter" --reporters="./gh_ann_reporter.js" --coverage
      - uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
        with:
          directory: ./web/app/coverage
          flags: unittests,javascript

  rust:
    name: Rust
    runs-on: ${{ vars.LINKERD2_RUNNER || 'ubuntu-24.04' }}
    timeout-minutes: 15
    container:
      image: docker://rust:1.88.0
      options: --security-opt seccomp=unconfined
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      - shell: bash
        run: mkdir -p target && cd target && bin/scurl -v https://github.com/xd009642/tarpaulin/releases/download/0.27.3/cargo-tarpaulin-x86_64-unknown-linux-musl.tar.gz | tar zxvf - && chmod 755 cargo-tarpaulin
      - run: target/cargo-tarpaulin tarpaulin --workspace --out Xml
      - uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
        with:
          flags: unittests,rust
