name: chipyard-ci-process

on:
  # run ci on pull requests targeting following branches (runs on the merge commit)
  pull_request:
    branches:
      - main
      - '1.[0-9]*.x'

defaults:
  run:
    shell: bash -leo pipefail {0}

env:
  tools-cache-version: v17
  CI_DIR: ${{ secrets.BUILDDIR }}
  JVM_OPTS: -Xmx3200m # Customize the JVM maximum heap limit
  conda-env-name-no-time: cy-${{ github.run_id }}
  workflow-timestamp: ${{ github.event.pull_request.updated_at }}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  cancel-prior-workflows:
    name: cancel-prior-workflows
    runs-on: ubuntu-latest
    steps:
      - name: Cancel Previous Runs
        uses: styfle/cancel-workflow-action@0.11.0
        with:
          access_token: ${{ github.token }}

  # Set up a set of boolean conditions to control which branches of the CI
  # workflow will execute This is based off the conditional job execution
  # example here: https://github.com/dorny/paths-filter#examples
  change-filters:
    name: filter-jobs-on-changes
    runs-on: ubuntu-latest
    # Queried by downstream jobs to determine if they should run.
    outputs:
      needs-rtl: ${{ steps.filter.outputs.all_count != steps.filter.outputs.skip-rtl_count }}

    steps:
      - uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: |
            all:
              - '**'

            # If any of the files changed match, do a doc build
            docs: &docs-filter
              - 'docs/**'
              - '.readthedocs.yml'

            # If all files match to this filter, skip the main ci pipeline
            skip-rtl:
              - *docs-filter
              - '**/*.md'
              - '**/.gitignore'
              - '.github/ISSUE_TEMPLATE/**'

  commit-on-master-check:
    name: commit-on-master-check
    needs: change-filters
    if: needs.change-filters.outputs.needs-rtl == 'true'
    runs-on: ubuntu-latest
    container:
      image: ucbbar/chipyard-ci-image:3f9150
      options: --entrypoint /bin/bash
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
        with:
          install-collateral: false
      - name: Check commits of each submodule
        run: |
            conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools
            .github/scripts/check-commit.sh

  tutorial-setup-check:
    name: tutorial-setup-check
    needs: change-filters
    if: needs.change-filters.outputs.needs-rtl == 'true'
    runs-on: ubuntu-latest
    container:
      image: ucbbar/chipyard-ci-image:3f9150
      options: --entrypoint /bin/bash
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
        with:
          install-collateral: false
      - name: Check that the tutorial-setup patches apply
        run: |
            conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools
            scripts/tutorial-setup.sh

  documentation-check:
    name: documentation-check
    needs: change-filters
    runs-on: ubuntu-latest
    container:
      image: ucbbar/chipyard-ci-image:3f9150
      options: --entrypoint /bin/bash
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
        with:
          install-collateral: false
      - name: Check that documentation builds with no warnings/errors
        run: |
          conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools
          make -C docs html
      - name: Show error log from sphinx if failed
        if: ${{ failure() }}
        run: cat /tmp/sphinx-err*.log

  build-extra-tests:
    name: build-extra-tests
    needs: [change-filters]
    if: needs.change-filters.outputs.needs-rtl == 'true'
    runs-on: ubuntu-latest
    container:
      image: ucbbar/chipyard-ci-image:3f9150
      options: --entrypoint /bin/bash
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Generate keys
        id: genkey
        run: |
          echo "::set-output name=extra-tests-cache-key::extra-tests-${{ github.sha }}"
      - uses: actions/cache@v3
        id: build-extra-tools-cache
        with:
          path: extra-tests-install
          key: ${{ steps.genkey.outputs.extra-tests-cache-key }}
          restore-keys: ${{ steps.genkey.outputs.extra-tests-cache-key }}
      - name: Build extra tests
        run: |
            conda activate ${{ env.conda-env-name-no-time }}-$(date --date "${{ env.workflow-timestamp }}" +%Y%m%d)-riscv-tools
            .github/scripts/build-extra-tests.sh

  create-conda-env-knight:
    name: create-conda-env-knight
    needs: [change-filters, cancel-prior-workflows]
    if: needs.change-filters.outputs.needs-rtl == 'true'
    runs-on: knight
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Cleanup conda
        uses: ./.github/actions/cleanup-conda
      - name: Create conda env
        uses: ./.github/actions/create-conda-env

  create-conda-env-ferry:
    name: create-conda-env-ferry
    needs: [change-filters, cancel-prior-workflows]
    if: needs.change-filters.outputs.needs-rtl == 'true'
    runs-on: ferry
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Cleanup conda
        uses: ./.github/actions/cleanup-conda
      - name: Create conda env
        uses: ./.github/actions/create-conda-env

  # Sentinel job to simplify how we specify which that basic setup is complete
  #
  # When adding new prep jobs, please add them to `needs` below
  setup-complete:
    name: setup-complete
    needs: [create-conda-env-knight, create-conda-env-ferry, build-extra-tests]
    runs-on: ubuntu-latest
    steps:
      - name: Set up complete
        run: echo Set up is complete!

  ##########################################################################

  prepare-chipyard-cores:
    name: prepare-chipyard-cores
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-cores"

  prepare-chipyard-constellation:
    name: prepare-chipyard-constellation
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-constellation"

  prepare-chipyard-peripherals:
    name: prepare-chipyard-peripherals
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-peripherals"

  prepare-chipyard-accels:
    name: prepare-chipyard-accels
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-accels"
          toolchain: "esp-tools"

  prepare-chipyard-tracegen:
    name: prepare-chipyard-tracegen
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-tracegen"

  prepare-chipyard-other:
    name: prepare-chipyard-other
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-other"

  prepare-chipyard-fpga:
    name: prepare-chipyard-fpga
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Build RTL on self-hosted
        uses: ./.github/actions/prepare-rtl
        with:
          group-key: "group-fpga"
          build-type: "fpga"

  ##########################################################################

  chipyard-rocket-run-tests:
    name: chipyard-rocket-run-tests
    needs: prepare-chipyard-cores
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-cores"
          project-key: "chipyard-rocket"

  chipyard-hetero-run-tests:
    name: chipyard-hetero-run-tests
    needs: prepare-chipyard-cores
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-cores"
          project-key: "chipyard-hetero"

  chipyard-boom-run-tests:
    name: chipyard-boom-run-tests
    needs: prepare-chipyard-cores
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-cores"
          project-key: "chipyard-boom"

  chipyard-cva6-run-tests:
    name: chipyard-cva6-run-tests
    needs: prepare-chipyard-cores
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-cores"
          project-key: "chipyard-cva6"

  chipyard-ibex-run-tests:
    name: chipyard-ibex-run-tests
    needs: prepare-chipyard-cores
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-cores"
          project-key: "chipyard-ibex"

  chipyard-sodor-run-tests:
    name: chipyard-sodor-run-tests
    needs: prepare-chipyard-cores
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-cores"
          project-key: "chipyard-sodor"

  chipyard-fftgenerator-run-tests:
    name: chipyard-fftgenerator-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-fftgenerator"

  chipyard-dmirocket-run-tests:
    name: chipyard-dmirocket-run-tests
    needs: prepare-chipyard-peripherals
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-peripherals"
          project-key: "chipyard-dmirocket"

  chipyard-spiflashwrite-run-tests:
    name: chipyard-spiflashwrite-run-tests
    needs: prepare-chipyard-peripherals
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
          ls -alh .
          rm -rf ${{ github.workspace }}/* || true
          rm -rf ${{ github.workspace }}/.* || true
          ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-peripherals"
          project-key: "chipyard-spiflashwrite"

  chipyard-spiflashread-run-tests:
    name: chipyard-spiflashread-run-tests
    needs: prepare-chipyard-peripherals
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
          ls -alh .
          rm -rf ${{ github.workspace }}/* || true
          rm -rf ${{ github.workspace }}/.* || true
          ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-peripherals"
          project-key: "chipyard-spiflashread"

  chipyard-lbwif-run-tests:
    name: chipyard-lbwif-run-tests
    needs: prepare-chipyard-peripherals
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-peripherals"
          project-key: "chipyard-lbwif"

  chipyard-sha3-run-tests:
    name: chipyard-sha3-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-sha3"
          toolchain: "esp-tools"

  chipyard-streaming-fir-run-tests:
    name: chipyard-streaming-fir-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-streaming-fir"

  chipyard-streaming-passthrough-run-tests:
    name: chipyard-streaming-passthrough-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-streaming-passthrough"

  chipyard-hwacha-run-tests:
    name: chipyard-hwacha-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-hwacha"
          toolchain: "esp-tools"

  chipyard-gemmini-run-tests:
    name: chipyard-gemmini-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-gemmini"
          toolchain: "esp-tools"

  chipyard-nvdla-run-tests:
    name: chipyard-nvdla-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-nvdla"

  chipyard-mempress-run-tests:
    name: chipyard-mempress-run-tests
    needs: prepare-chipyard-accels
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-accels"
          project-key: "chipyard-mempress"
          toolchain: "esp-tools"


  tracegen-boom-run-tests:
    name: tracegen-boom-run-tests
    needs: prepare-chipyard-tracegen
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-tracegen"
          project-key: "tracegen-boom"

  tracegen-run-tests:
    name: tracegen-run-tests
    needs: prepare-chipyard-tracegen
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-tracegen"
          project-key: "tracegen"

  icenet-run-tests:
    name: icenet-run-tests
    needs: prepare-chipyard-other
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-other"
          project-key: "icenet"

  testchipip-run-tests:
    name: testchipip-run-tests
    needs: prepare-chipyard-other
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-other"
          project-key: "testchipip"

  constellation-run-tests:
    name: constellation-run-tests
    needs: prepare-chipyard-other
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-other"
          project-key: "constellation"

  chipyard-constellation-run-tests:
    name: chipyard-constellation-run-tests
    needs: prepare-chipyard-constellation
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests
        uses: ./.github/actions/run-tests
        with:
          group-key: "group-constellation"
          project-key: "chipyard-constellation"


  firesim-run-tests:
    name: firesim-run-tests
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests on self-hosted
        uses: ./.github/actions/run-tests
        with:
          group-key: "extra-tests"
          project-key: "firesim"
          run-script: "remote-run-firesim-scala-tests.sh"

  fireboom-run-tests:
    name: fireboom-run-tests
    needs: setup-complete
    runs-on: self-hosted
    steps:
      - name: Delete old checkout
        run: |
            ls -alh .
            rm -rf ${{ github.workspace }}/* || true
            rm -rf ${{ github.workspace }}/.* || true
            ls -alh .
      - name: Checkout
        uses: actions/checkout@v3
      - name: Git workaround
        uses: ./.github/actions/git-workaround
      - name: Create conda env
        uses: ./.github/actions/create-conda-env
      - name: Run tests on self-hosted
        uses: ./.github/actions/run-tests
        with:
          group-key: "extra-tests"
          project-key: "fireboom"
          run-script: "remote-run-firesim-scala-tests.sh"

  # Sentinel job to simplify how we specify which checks need to pass in branch
  # protection and in Mergify
  #
  # When adding new top level jobs, please add them to `needs` below
  all_tests_passed:
    name: "all tests passed"
    needs: [commit-on-master-check,
            tutorial-setup-check,
            documentation-check,
            chipyard-rocket-run-tests,
            chipyard-hetero-run-tests,
            chipyard-boom-run-tests,
            chipyard-cva6-run-tests,
            chipyard-ibex-run-tests,
            chipyard-sodor-run-tests,
            chipyard-dmirocket-run-tests,
            chipyard-fftgenerator-run-tests,
            chipyard-spiflashread-run-tests,
            chipyard-spiflashwrite-run-tests,
            chipyard-lbwif-run-tests,
            chipyard-sha3-run-tests,
            chipyard-streaming-fir-run-tests,
            chipyard-streaming-passthrough-run-tests,
            chipyard-hwacha-run-tests,
            chipyard-gemmini-run-tests,
            chipyard-nvdla-run-tests,
            chipyard-mempress-run-tests,
            chipyard-constellation-run-tests,
            tracegen-boom-run-tests,
            tracegen-run-tests,
            icenet-run-tests,
            testchipip-run-tests,
            constellation-run-tests,
            prepare-chipyard-fpga, # firesim-run-tests,
            fireboom-run-tests]
    runs-on: ubuntu-latest
    steps:
      - run: echo Success!
