Fix build rules to update generated opam files, and improve CI workflows #2165
Workflow file for this run
This file contains hidden or 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: Main Workflow | |
| # use fields.git-main-branch to change from master | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| push: | |
| branches: | |
| - master | |
| # Cancel runs upon PR updates: | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| ocaml-compiler: | |
| - 4.14.2 | |
| skip_test: | |
| - false | |
| build_vsix: | |
| - true | |
| include: | |
| - os: ubuntu-latest | |
| ocaml-compiler: 4.14.0 | |
| skip_test: true | |
| build_vsix: false | |
| runs-on: ${{ matrix.os }} | |
| # use fields.github-workflow-env to add something here | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set git user | |
| run: | | |
| git config --global user.name github-actions | |
| git config --global user.email github-actions-bot@users.noreply.github.com | |
| - name: Run apt update | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt update | |
| - name: Use OCaml ${{ matrix.ocaml-compiler }} | |
| uses: avsm/setup-ocaml@v3 | |
| with: | |
| ocaml-compiler: ${{ matrix.ocaml-compiler }} | |
| opam-pin: false | |
| - name: Retrieve cache of local opam switch | |
| uses: actions/cache@v4 | |
| id: cache-opam | |
| with: | |
| path: _opam | |
| key: v4-${{ runner.os }}-superbol-studio-oss-${{ matrix.ocaml-compiler }}-${{ hashFiles('opam/*.opam', 'vendors/**/*.opam', '.github/workflows/workflow.yml') }}-skip_tests=${{ matrix.skip_test }}-repo= | |
| # use fields.opam-repo = "git+https://" to add an 'extra' opam repository | |
| # Use fields.github-workflow-before-build to add something here | |
| - run: git submodule init | |
| - run: git submodule update | |
| - name: Build and install GnuCOBOL 4.x | |
| run: | | |
| if ${{ matrix.os == 'ubuntu-latest' }}; then | |
| sudo apt-get install -y autoconf automake flex bison help2man texinfo wget libgmp-dev libdb-dev | |
| bash scripts/install-gc4.sh import/gnucobol4 /opt/gnucobol-4.x | |
| elif ${{ matrix.os == 'macos-latest' }}; then | |
| brew update | |
| brew install autoconf automake libtool bison help2man texinfo berkeley-db@5 json-c libiconv | |
| HOMEBREW_ROOT="$(brew --prefix)/opt" | |
| export TERM=vt100 | |
| export PATH="$HOMEBREW_ROOT/bison/bin:${PATH}" | |
| export LDFLAGS="-L$HOMEBREW_ROOT/berkeley-db@5/lib -L$HOMEBREW_ROOT/libiconv/lib ${LDFLAGS}" | |
| export CPPFLAGS="-I$HOMEBREW_ROOT/berkeley-db@5/include -I$HOMEBREW_ROOT/libiconv/include ${CPPFLAGS}" | |
| sudo mkdir -p /opt/gnucobol-4.x | |
| sudo chmod a+rwx /opt/gnucobol-4.x | |
| bash scripts/install-gc4.sh import/gnucobol4 /opt/gnucobol-4.x | |
| fi | |
| echo '/opt/gnucobol-4.x/bin' >> $GITHUB_PATH | |
| echo 'LD_LIBRARY_PATH=/opt/gnucobol-4.x/lib:$LD_LIBRARY_PATH' >> $GITHUB_ENV | |
| echo 'HAVE_LIBCOB5=true' >> $GITHUB_ENV | |
| if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' }} | |
| - name: Skip build and install of GnuCOBOL 4.x | |
| run: | | |
| echo 'HAVE_LIBCOB5=false' >> $GITHUB_ENV | |
| if: ${{ matrix.os != 'ubuntu-latest' && matrix.os != 'macos-latest' }} | |
| - name: Pin local packages | |
| run: | | |
| for dir in . vendors/*; do opam pin add ${dir} -y --no-action; done | |
| - run: | | |
| if ${{ matrix.skip_test }} | |
| then | |
| opam install -y opam/*.opam --deps-only | |
| else | |
| opam install -y opam/*.opam --deps-only --with-test | |
| fi | |
| if: steps.cache-opam.outputs.cache-hit != 'true' | |
| name: Run opam install -y **/opam/*.opam --deps-only [ --with-test ] | |
| # Use fields.build-scripts to add more scripts to convert here | |
| - run: dos2unix scripts/*.sh | |
| if: matrix.os == 'windows-latest' | |
| # Use fields.github-workflow-before-build to add something here | |
| - name: Check project files | |
| run: | | |
| opam pin --yes "git+https://github.com/OCamlPro/drom.git#v0.9.3" | |
| make check-project | |
| if: ${{ matrix.ocaml-compiler == '4.14.2' && matrix.os == 'ubuntu-latest' && matrix.skip_test == 'true' }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '>=16' | |
| cache: 'npm' | |
| cache-dependency-path: '**/package-lock.json' | |
| if: matrix.build_vsix | |
| - run: make build | |
| # Use fields.github-workflow-after-build to add something here | |
| - run: make check-package.json | |
| - run: make dev-deps # install test dependencies | |
| if: ${{ ! matrix.skip_test }} | |
| - run: make test | |
| if: ${{ ! matrix.skip_test }} | |
| - name: Show test result on failure | |
| if: failure() | |
| run: cat _build/_autofonce/results.log | |
| # Use fields.github-workflow-after-test to add something here | |
| - run: npm install && npm install esbuild | |
| if: matrix.build_vsix | |
| - run: make vsix-debug | |
| if: matrix.build_vsix | |
| - name: Upload VSIX artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: VSIX-${{ matrix.os }} | |
| path: superbol-vscode-oss-*.vsix | |
| compression-level: 0 # no compression (already a zip archive) | |
| if: matrix.build_vsix | |
| - run: make vsix-debug TARGET_PLAT=universal | |
| if: ${{ matrix.build_vsix && matrix.os == 'ubuntu-latest' }} | |
| - name: Upload universal VSIX artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: VSIX-universal | |
| path: superbol-vscode-oss-*-universal-*.vsix | |
| compression-level: 0 # no compression (already a zip archive) | |
| if: ${{ matrix.build_vsix && matrix.os == 'ubuntu-latest' }} | |
| # - name: Check whether source is well formatted | |
| # run: make fmt | |
| # continue-on-error: true | |
| # if: matrix.ocaml-compiler == '4.14.2' && matrix.os == 'ubuntu-latest' | |
| - name: Build documentation | |
| if: github.ref == 'refs/heads/master' && matrix.ocaml-compiler == '4.14.2' && matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt install -yqq python3-sphinx python3-sphinx-rtd-theme | |
| opam install -y dune odoc | |
| make doc | |
| touch _drom/docs/.nojekyll | |
| touch _drom/docs/sphinx/.nojekyll | |
| touch _drom/docs/doc/.nojekyll | |
| - name: Deploy documentation | |
| uses: JamesIves/github-pages-deploy-action@3.6.2 | |
| if: github.ref == 'refs/heads/master' && matrix.ocaml-compiler == '4.14.2' && matrix.os == 'ubuntu-latest' | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BRANCH: gh-pages | |
| FOLDER: _drom/docs/ | |
| CLEAN: true | |
| # Use fields.github-workflow-trailer to add a trailer here | |
| - name: Cleanup local opam switch before caching | |
| run: | | |
| opam pin remove . --yes | |
| opam clean --switch-cleanup --logs | |
| find _opam -type f -a \( -name '*.cmt' -o -name '*.cmti' \) -delete | |
| if: steps.cache-opam.outputs.cache-hit != 'true' |