Skip to content

Commit

Permalink
Update deps + switch to opam on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alex35mil committed Feb 26, 2024
1 parent 8b31e42 commit a487553
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 149 deletions.
287 changes: 198 additions & 89 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ on:
pull_request:
branches:
- master
push:
branches:
- release

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
check:
name: PR check
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && github.base_ref == 'master' }}
strategy:
matrix:
os: [ubuntu-latest]
ocaml-version: [4.14.1]
node-version: [16.x]
os: [macOS-latest, windows-latest]

steps:
- name: Checkout repo
Expand All @@ -25,7 +30,7 @@ jobs:

- name: Print Yarn cache
id: print-yarn-cache
run: echo "::set-output name=yarn-cache::$(yarn cache dir)"
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore Yarn cache
id: yarn-cache
Expand All @@ -37,25 +42,71 @@ jobs:
- name: Install Yarn deps
run: yarn install

- name: Install Esy
run: npm install -g [email protected]
- name: Setup OCaml ${{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Install Opam deps
run: opam install . --deps-only --with-test

- name: Install Esy deps
run: esy install
- name: Build PPX
run: opam exec -- dune build

- name: Print Esy cache
id: print-esy-cache
run: node .github/workflows/scripts/print-esy-cache.js
- name: Build ReScript lib
run: |
cd lib
yarn run build
cd ../examples
yarn run build
- name: Restore Esy cache
id: esy-cache
- name: Run PPX tests
run: opam exec -- dune exec test.exe

- name: Run integration tests
run: |
cd specs
yarn run test
build_linux:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/release' }}
strategy:
matrix:
os: [ubuntu-latest]
ocaml-version: [4.14.1]
node-version: [16.x]
container:
image: alex35mil/alpine-3.19-ocaml-4.14-node-16.20-yarn-1.22-wtlK

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Print Yarn cache
id: print-yarn-cache
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore Yarn cache
id: yarn-cache
uses: actions/cache@v1
with:
path: ${{ steps.print-esy-cache.outputs.esy-cache }}
key: ${{ matrix.os }}-esy-${{ hashFiles('**/index.json') }}
path: ${{ steps.print-yarn-cache.outputs.yarn-cache }}
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install Yarn deps
run: yarn install

- name: Build ppx
run: esy build
- name: Setup OCaml ${{ matrix.ocaml-version }}
run: opam init -a --disable-sandboxing --compiler=${{ matrix.ocaml-version }}

- name: Install Opam deps
run: opam install . --deps-only --with-test

- name: Build PPX
run: opam exec -- dune build --profile static

- name: Build ReScript lib
run: |
Expand All @@ -64,10 +115,8 @@ jobs:
cd ../examples
yarn run build
- name: Run ppx tests
# FIXME: Snapshot tests are broken on Win
if: matrix.os != 'windows-latest'
run: esy x test.exe
- name: Run PPX tests
run: opam exec -- dune exec test.exe

- name: Run integration tests
run: |
Expand All @@ -80,53 +129,49 @@ jobs:
name: ${{ matrix.os }}
path: _build/default/ppx/bin/bin.exe

build_linux:
build_macos:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/release' }}
strategy:
matrix:
os: [ubuntu-latest]

container:
image: alexfedoseev/alpine-node-yarn-esy:0.0.10
os: [macos-13, macos-14]
ocaml-version: [4.14.1]
node-version: [16.x]

steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Apply static linking patch
run: git apply linux.patch
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Print Yarn cache
id: print-yarn-cache
run: echo "::set-output name=yarn-cache::$(yarn cache dir)"
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore Yarn cache
id: yarn-cache
uses: actions/cache@v1
with:
path: ${{ steps.print-yarn-cache.outputs.yarn-cache }}
key: ${{ matrix.os }}-yarn-${{ hashFiles('yarn.lock') }}-v1
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install Yarn deps
run: yarn install

- name: Install Esy deps
run: esy install

- name: Print Esy cache
id: print-esy-cache
run: node .github/workflows/scripts/print-esy-cache.js

- name: Restore Esy cache
id: esy-cache
uses: actions/cache@v1
- name: Setup OCaml ${{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
path: ${{ steps.print-esy-cache.outputs.esy-cache }}
key: ${{ matrix.os }}-esy-${{ hashFiles('esy.lock/index.json') }}
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Build ppx
run: esy build
- name: Install Opam deps
run: opam install . --deps-only --with-test

- name: Build PPX
run: opam exec -- dune build

- name: Build ReScript lib
run: |
Expand All @@ -135,27 +180,29 @@ jobs:
cd ../examples
yarn run build
- name: Run ppx tests
run: esy x test.exe
- name: Run PPX tests
run: opam exec -- dune exec test.exe

# FIXME: Integration tests are broken on Linux
# - name: Run integration tests
# run: |
# cd specs
# yarn run test
- name: Run integration tests
run: |
cd specs
yarn run test
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.os }}
path: _build/default/ppx/bin/bin.exe

rc:
needs:
- build
- build_linux
name: Prepare RC
runs-on: ubuntu-latest
build_windows:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/release' }}
strategy:
matrix:
os: [windows-latest]
ocaml-version: [4.14.1]
node-version: [16.x]

steps:
- name: Checkout repo
Expand All @@ -164,45 +211,107 @@ jobs:
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: ${{ matrix.node-version }}

- name: Download Linux artifacts
uses: actions/download-artifact@v1
with:
name: ubuntu-latest
path: _bin/linux
- name: Print Yarn cache
id: print-yarn-cache
run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Download macOS artifacts
uses: actions/download-artifact@v1
- name: Restore Yarn cache
id: yarn-cache
uses: actions/cache@v1
with:
name: macOS-latest
path: _bin/darwin
path: ${{ steps.print-yarn-cache.outputs.yarn-cache }}
key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install Yarn deps
run: yarn install

- name: Download Windows artifacts
uses: actions/download-artifact@v1
- name: Setup OCaml ${{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
name: windows-latest
path: _bin/windows
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Install Opam deps
run: opam install . --deps-only --with-test

- name: Move artifacts
- name: Build PPX
run: opam exec -- dune build

- name: Build ReScript lib
run: |
mkdir -p _release/bin
mv _bin/darwin/bin.exe _release/bin/re-formality-ppx-darwin-x64.exe
mv _bin/windows/bin.exe _release/bin/re-formality-ppx-win-x64.exe
mv _bin/linux/bin.exe _release/bin/re-formality-ppx-linux-x64.exe
rm -rf _bin
cd lib
yarn run build
cd ../examples
yarn run build
- name: Move lib files
- name: Run PPX tests
run: opam exec -- dune exec test.exe

- name: Run integration tests
run: |
mkdir -p _release/src
cp README.md _release/README.md
cp lib/bsconfig.json _release/bsconfig.json
cp -a lib/src/. _release/src/
cp .github/workflows/scripts/postinstall.js _release/postinstall.js
node .github/workflows/scripts/write-package-json.js
- name: Upload release
cd specs
yarn run test
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: release
path: _release
name: ${{ matrix.os }}
path: _build/default/ppx/bin/bin.exe

# rc:
# needs:
# - build
# - build_linux
# name: Prepare RC
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout repo
# uses: actions/checkout@v2
#
# - name: Setup Node ${{ matrix.node-version }}
# uses: actions/setup-node@v1
# with:
# node-version: 16.x
#
# - name: Download Linux artifacts
# uses: actions/download-artifact@v1
# with:
# name: ubuntu-latest
# path: _bin/linux
#
# - name: Download macOS artifacts
# uses: actions/download-artifact@v1
# with:
# name: macOS-latest
# path: _bin/darwin
#
# - name: Download Windows artifacts
# uses: actions/download-artifact@v1
# with:
# name: windows-latest
# path: _bin/windows
#
# - name: Move artifacts
# run: |
# mkdir -p _release/bin
# mv _bin/darwin/bin.exe _release/bin/re-formality-ppx-darwin-x64.exe
# mv _bin/windows/bin.exe _release/bin/re-formality-ppx-win-x64.exe
# mv _bin/linux/bin.exe _release/bin/re-formality-ppx-linux-x64.exe
# rm -rf _bin
#
# - name: Move lib files
# run: |
# mkdir -p _release/src
# cp README.md _release/README.md
# cp lib/bsconfig.json _release/bsconfig.json
# cp -a lib/src/. _release/src/
# cp .github/workflows/scripts/postinstall.js _release/postinstall.js
# node .github/workflows/scripts/write-package-json.js
#
# - name: Upload release
# uses: actions/upload-artifact@v1
# with:
# name: release
# path: _release
Loading

0 comments on commit a487553

Please sign in to comment.