diff --git a/.github/actions/test-oxcaml/action.yml b/.github/actions/test-oxcaml/action.yml new file mode 100644 index 000000000..2dada6c91 --- /dev/null +++ b/.github/actions/test-oxcaml/action.yml @@ -0,0 +1,88 @@ +--- +name: Setup OxCaml with a predefined set of opam packages +inputs: + ocaml-compiler: + description: The OCaml compiler switch to install + required: true + + opam-disable-sandboxing: + description: Disable the opam sandboxing feature. + required: false + default: "false" + +runs: + using: "composite" + steps: + - name: Install required packages on Linux + shell: sh + run: | + set -e + if [ "$(uname)" = "Linux" ]; then + if [ -f /etc/os-release ]; then + . /etc/os-release + echo "Detected Linux distro: $ID" + case "$ID" in + ubuntu|debian) + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential curl git rsync sudo unzip nano + ;; + arch) + pacman -Sy --noconfirm make gcc patch tar ca-certificates git \ + rsync curl sudo bash nano coreutils xz ncurses diffutils \ + unzip + ;; + *) + echo "Unsupported Linux distro: $ID" + exit 1 + ;; + esac + else + echo "Missing /etc/os-release on Linux?" + exit 1 + fi + else + # Installing autoconf beforehand prevents recompilation of the + # compiler when restoring from the cache + brew install autoconf + fi + + - name: Get hash of the ocaml-variant opam file + id: hash-opam-file + shell: bash + env: + OCAML_COMPILER: ${{ inputs.ocaml-compiler }} + run: | + set -e + OPAM_FILE="packages/ocaml-variants/${OCAML_COMPILER}/opam" + + if command -v sha256sum >/dev/null 2>&1; then + COMMAND="sha256sum" + elif command -v shasum >/dev/null 2>&1; then + COMMAND="shasum -a 256" + else + echo "ERROR: Neither sha256sum nor shasum is available." >&2 + exit 1 + fi + + HASH=$($COMMAND "$OPAM_FILE" | awk '{print $1}') + echo "hash=${HASH}" >> "$GITHUB_OUTPUT" + + - uses: ocaml/setup-ocaml@v3.3.5 + with: + cache-prefix: ${{ steps.hash-opam-file.outputs.hash }} + ocaml-compiler: ${{ inputs.ocaml-compiler }} + opam-pin: false + opam-disable-sandboxing: ${{ inputs.opam-disable-sandboxing }} + opam-repositories: | + oxcaml: . + default: https://github.com/ocaml/opam-repository.git + + - name: Install common opam packages + shell: bash + run: | + opam --version + opam repository list + opam list + opam install ocamlformat merlin ocaml-lsp-server utop parallel core_unix + opam list diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95a4e67ca..8bca1ed14 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,41 +8,47 @@ on: schedule: - cron: "30 0 * * *" +# For info on the OS versions, architecture, etc., see +# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories + jobs: - test-setup: - env: - OCAML_VARIANT: ocaml-variants.5.2.0+ox + test-linux: strategy: fail-fast: false matrix: - # For info on the OS versions, architecture, etc., see - # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories - os: [ubuntu-latest, ubuntu-24.04-arm, macos-13, macos-latest] + image: [ubuntu:24.04, debian:bookworm] + os: [ubuntu-latest, ubuntu-24.04-arm] + include: + - image: archlinux:latest + os: ubuntu-latest runs-on: ${{ matrix.os }} + container: + image: ${{ matrix.image }} steps: + - name: Check OS info + run: | + uname -a + - name: Checkout the repository uses: actions/checkout@v4 - - name: Get hash of the ocaml-variant opam file - id: hash-opam-file - run: | - HASH=$(shasum -a 256 packages/ocaml-variants/${OCAML_VARIANT}/opam | awk '{print $1}') - echo "hash=${HASH}" >> "$GITHUB_OUTPUT" - - - uses: ocaml/setup-ocaml@v3 + - name: Run Test OxCaml action + uses: ./.github/actions/test-oxcaml with: - # Invalidate cache when opam file for the ocaml-variant changes - cache-prefix: ${{ steps.hash-opam-file.outputs.hash }} - ocaml-compiler: ${{ env.OCAML_VARIANT }} - opam-pin: false - opam-repositories: | - oxcaml: . - default: https://github.com/ocaml/opam-repository.git + ocaml-compiler: ocaml-variants.5.2.0+ox + opam-disable-sandboxing: true - - name: opam install packages - run: | - opam --version - opam repository list - opam list - opam install ocamlformat merlin ocaml-lsp-server utop parallel core_unix - opam list + test-macos: + strategy: + fail-fast: false + matrix: + os: [macos-13, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Run Test OxCaml action + uses: ./.github/actions/test-oxcaml + with: + ocaml-compiler: ocaml-variants.5.2.0+ox