CI: upload server binary #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CN Server CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
# Cancel in-progress job when a new push is performed | |
concurrency: | |
group: ci-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
strategy: | |
matrix: | |
ocaml-version: [4.14.1] | |
os: [ubuntu-22.04] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up OCaml | |
uses: ocaml/setup-ocaml@v3 | |
with: | |
ocaml-compiler: ${{ matrix.ocaml-version }} | |
- name: Link lockfile | |
working-directory: cn-lsp/server | |
run: ln -s cnlsp.opam.locked-${{ matrix.ocaml-version }} cnlsp.opam.locked | |
- name: Restore `_opam` | |
id: cache-opam-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: cn-lsp/server/_opam | |
key: ${{ matrix.ocaml-version }}-${{ hashFiles('cn-lsp/server/cnlsp.opam.locked') }} | |
- name: Install server dependencies | |
working-directory: cn-lsp/server | |
# `opam switch show ||` allows this operation to succeed trivially if | |
# opam believes the switch already exists, which it will if it sees our | |
# restored `_opam` on disk | |
run: opam switch show || opam switch create . ocaml.${{ matrix.ocaml-version }} --deps-only --locked -y | |
- name: Cache `_opam` | |
if: steps.cache-opam-restore.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v4 | |
with: | |
path: cn-lsp/server/_opam | |
key: ${{ steps.cache-opam-restore.outputs.cache-primary-key }} | |
- name: Build server | |
working-directory: cn-lsp/server | |
run: eval $(opam env) && dune build | |
- name: Run server tests | |
working-directory: cn-lsp/server | |
run: eval $(opam env) && dune test | |
- name: Install server | |
# if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
working-directory: cn-lsp/server | |
run: opam install . -y | |
- name: Upload server binary | |
# if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cn-lsp-server-${{ matrix.os }} | |
path: cn-lsp/server/_opam/bin/cn-lsp-server | |
- name: Upload Cerberus runtime | |
# if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cerberus-runtime | |
path: cn-lsp/server/_opam/lib/cerberus/runtime |