Ensure we can compile for every major version #87
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
# | |
# Source: https://github.com/JetBrains/intellij-platform-plugin-template/blob/main/.github/workflows/build.yml | |
# - removing a lot of unused code | |
# - removing restrictions on versions | |
# - using gradle build action | |
# - installing opam, ocaml with opam, and ocaml | |
# License: https://github.com/JetBrains/intellij-platform-plugin-template/blob/main/LICENSE | |
# | |
# Note: https://github.com/marketplace/actions/qodana-scan | |
name: Build | |
on: | |
# Trigger the workflow on pushes to only the 'main' branch | |
# (this avoids duplicate checks being run e.g. for dependabot pull requests) | |
push: | |
branches: [main] | |
# Trigger the workflow on any pull request | |
pull_request: | |
jobs: | |
# Run Gradle Wrapper Validation Action to verify the wrapper's checksum | |
# Run verifyPlugin, IntelliJ Plugin Verifier, and test Gradle tasks | |
# Build plugin and provide the artifact for the next workflow jobs | |
build: | |
name: Build | |
strategy: | |
fail-fast: false | |
# number of tests = card(os) * card(ocaml-compiler) * card(platform-version) | |
# = 20 | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
ocaml-compiler: | |
- 4.05.0 | |
# - 4.08.1 | |
- 4.13.1 | |
platform-version: | |
- 203 | |
- 211 | |
- 212 | |
- 213 | |
- 221 | |
runs-on: ${{ matrix.os }} | |
steps: | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v2 | |
# Validate wrapper | |
# https://github.com/gradle/wrapper-validation-action | |
- name: Gradle Wrapper Validation | |
uses: gradle/wrapper-validation-action@v1 | |
# Setup Java 11 environment for the next steps | |
- name: Setup Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: zulu | |
java-version: 11 | |
cache: gradle | |
# Still not done by the action | |
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# I'm not using https://github.com/ocaml/setup-ocaml, | |
# because the switch is installed in an invalid location (a folder named _opam, | |
# while I need a folder named after its ocaml version) | |
- name: Use OCaml ${{ matrix.ocaml-compiler }} | |
uses: ocaml/setup-ocaml@v2 | |
with: | |
ocaml-compiler: ${{ matrix.ocaml-compiler }} | |
# warn: the two others "sed" didn't work, but I don't care :angry_noises: | |
- name: Move switch to .opam (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
mkdir -p D:\\cygwin\\home\\runneradmin\\.opam | |
mv D:\\a\\intellij-ocaml\\intellij-ocaml\\_opam D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }} | |
sed -i 's/D:\/a\/intellij-ocaml\/intellij-ocaml""/${{ matrix.ocaml-compiler }}""\nswitch: ""${{ matrix.ocaml-compiler }}""/g' D:\\.opam\\config | |
sed -i 's/D:\\a\\intellij-ocaml\\intellij-ocaml\\_opam/D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}/g' D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\.opam-switch\\environment | |
sed -i 's/D:\\a\\intellij-ocaml\\intellij-ocaml\\_opam/D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}/g' D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\.opam-switch\\config\\ocaml.config | |
mkdir -p D:\\a\\intellij-ocaml\\intellij-ocaml\\_opam\\bin\\ | |
cp D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\bin\\ocamlrun.exe D:\\a\\intellij-ocaml\\intellij-ocaml\\_opam\\bin\\ocamlrun.exe | |
- name: Check files (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\bin\\ocaml -vnum | |
D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\bin\\ocamlc -vnum | |
D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\bin\\ocaml.exe -vnum | |
D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\bin\\ocamlc.exe -vnum | |
env: | |
OCAMLLIB: "D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\lib\\ocaml" | |
# We are moving the folder with the switch | |
# Editing the configurations | |
# creating a copy to OCAML RUN (ocaml will always look for it here...) | |
# Then we are setting OCAMLLIB (needed, because, we moved the lib folder) | |
# \see https://docs.github.com/en/actions/learn-github-actions/environment-variables | |
# \see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | |
- name: Move switch to .opam (Linux) | |
if: runner.os != 'Windows' | |
run: | | |
mv /home/runner/work/intellij-ocaml/intellij-ocaml/_opam /home/runner/.opam/${{ matrix.ocaml-compiler }} | |
sed -i 's/\/home\/runner\/work\/intellij-ocaml\/intellij-ocaml\"/${{ matrix.ocaml-compiler }}\"\nswitch: \"${{ matrix.ocaml-compiler }}\"/g' /home/runner/.opam/config | |
sed -i 's/\/home\/runner\/work\/intellij-ocaml\/intellij-ocaml\/_opam/\/home\/runner\/.opam\/${{ matrix.ocaml-compiler }}/g' /home/runner/.opam/${{ matrix.ocaml-compiler }}/.opam-switch/environment | |
sed -i 's/\/home\/runner\/work\/intellij-ocaml\/intellij-ocaml\/_opam/\/home\/runner\/.opam\/${{ matrix.ocaml-compiler }}/g' /home/runner/.opam/${{ matrix.ocaml-compiler }}/.opam-switch/config/ocaml.config | |
mkdir -p /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ | |
echo -n "#!" > /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ocamlrun | |
echo "/bin/bash" >> /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ocamlrun | |
echo -n "/home/runner/.opam/${{ matrix.ocaml-compiler }}/bin/ocamlrun" >> /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ocamlrun | |
echo -n " $" >> /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ocamlrun | |
echo -n "@" >> /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ocamlrun | |
chmod +x /home/runner/work/intellij-ocaml/intellij-ocaml/_opam/bin/ocamlrun | |
echo "OCAMLLIB=/home/runner/.opam/${{ matrix.ocaml-compiler }}/lib/ocaml" >> $GITHUB_ENV | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install ocaml | |
- name: Check files (Linux) | |
if: runner.os != 'Windows' | |
run: | | |
/home/runner/.opam/${{ matrix.ocaml-compiler }}/bin/ocaml -vnum | |
/home/runner/.opam/${{ matrix.ocaml-compiler }}/bin/ocamlc -vnum | |
/bin/ocaml -vnum | |
/bin/ocamlc -vnum | |
# For each "version" of IntelliJ | |
- name: Use gradle-${{ matrix.platform-version }}.properties (Linux) | |
if: runner.os != 'Windows' | |
run: sed -i 's/platformVersion=[^\n]*/platformVersion=${{ matrix.platform-version }}/g' ./gradle.properties | |
- name: Use gradle-${{ matrix.platform-version }}.properties (Windows) | |
if: runner.os == 'Windows' | |
run: sed -i 's/platformVersion=[^\n]*/platformVersion=${{ matrix.platform-version }}/g' .\gradle.properties | |
# Run tests | |
# https://github.com/gradle/gradle-build-action | |
- name: Test with Gradle (Linux) | |
if: runner.os != 'Windows' | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: test | |
- name: Test with Gradle (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
./gradlew build | |
./gradlew -i test | |
env: | |
OCAMLLIB: "D:\\cygwin\\home\\runneradmin\\.opam\\${{ matrix.ocaml-compiler }}\\lib\\ocaml" | |
# Run Qodana inspections | |
# - name: Qodana - Code Inspection | |
# uses: JetBrains/qodana-action@v4.2.5 |