name: Run external tests

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - '**'

permissions: {}

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: '-D warnings'

jobs:
  external-tests:
    name: Run mold tests
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    container:
      image: 'ubuntu:25.04'
    steps:
      - run: |
          apt-get update && apt-get -y install gcc g++ clang lld curl bubblewrap git zstd qemu-user \
              binutils-aarch64-linux-gnu binutils-riscv64-linux-gnu binutils-loongarch64-linux-gnu \
              gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-loongarch64-linux-gnu \
              g++-aarch64-linux-gnu g++-riscv64-linux-gnu g++-loongarch64-linux-gnu
      - name: Checkout
        uses: actions/checkout@v6
        with:
          persist-credentials: false
          submodules: recursive
      - uses: dtolnay/rust-toolchain@stable
        id: rust-toolchain
      - uses: Swatinem/rust-cache@v2
      - name: Check regressions
        run: WILD_TEST_CROSS=all cargo test --features mold_tests external_tests::mold_tests::check_mold_tests_regression
      - name: Check tests that should fail still fail
        continue-on-error: true
        run: WILD_TEST_CROSS=all cargo test --features mold_tests external_tests::mold_tests::verify_skipped_mold_tests_still_fail
