Fixes Kadabra-JS failing tests #651
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
| # This workflow will build a the whole project every day at midnight | |
| # It will build the Java part and the JS part | |
| # Every push to a branch will trigger the build | |
| # Every pull request will trigger the build | |
| name: nightly | |
| on: | |
| pull_request: | |
| # Every Monday at 09h00 | |
| schedule: | |
| - cron: "0 9 * * 1" | |
| permissions: | |
| checks: write | |
| contents: write | |
| env: | |
| JAVA_VERSION: 17 | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| jobs: | |
| build-java: | |
| name: Build Java | |
| runs-on: ubuntu-latest | |
| outputs: | |
| lara_ref: ${{ steps.repo-refs.outputs.lara_ref }} | |
| specs_ref: ${{ steps.repo-refs.outputs.specs_ref }} | |
| steps: | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: ${{ env.JAVA_VERSION }} | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| gradle-version: current | |
| dependency-graph: generate-and-submit | |
| - name: Checkout Kadabra | |
| uses: actions/checkout@v6 | |
| with: | |
| path: kadabra | |
| - name: Determine repository refs | |
| id: repo-refs | |
| shell: bash | |
| env: | |
| BRANCH_NAME: ${{ env.BRANCH_NAME }} | |
| BASE_BRANCH: ${{ github.base_ref }} | |
| run: | | |
| set -euo pipefail | |
| # For each dependency repository, determine which branch to checkout. | |
| # Priority order: | |
| # 1. A branch with the same name as the current branch | |
| # 2. If this is a PR, the target branch (base_ref) | |
| # 3. The default branch of the repository | |
| determine_ref() { | |
| local prefix=$1 | |
| local repo=$2 | |
| local url="https://github.com/${repo}.git" | |
| # Get the default branch | |
| local default_branch | |
| default_branch=$(git ls-remote --symref "$url" HEAD | awk '/^ref:/ {print $2}' | sed 's@refs/heads/@@') | |
| echo "${prefix}_default=${default_branch}" >> "$GITHUB_OUTPUT" | |
| echo "Default branch for ${repo} is '${default_branch}'" | |
| local ref_to_use="" | |
| # Priority 1: Same branch name | |
| if [ -n "$(git ls-remote --heads "$url" "refs/heads/${BRANCH_NAME}")" ]; then | |
| ref_to_use="${BRANCH_NAME}" | |
| echo "Using matching branch '${BRANCH_NAME}' in ${repo}" | |
| # Priority 2: PR target branch (if this is a PR) | |
| elif [ -n "${BASE_BRANCH}" ] && [ -n "$(git ls-remote --heads "$url" "refs/heads/${BASE_BRANCH}")" ]; then | |
| ref_to_use="${BASE_BRANCH}" | |
| echo "Using PR target branch '${BASE_BRANCH}' in ${repo}" | |
| # Priority 3: Default branch | |
| else | |
| ref_to_use="${default_branch}" | |
| echo "Using default branch '${default_branch}' for ${repo}" | |
| fi | |
| echo "${prefix}_ref=${ref_to_use}" >> "$GITHUB_OUTPUT" | |
| } | |
| determine_ref "lara" "specs-feup/lara-framework" | |
| determine_ref "specs" "specs-feup/specs-java-libs" | |
| - name: Echo checks | |
| run: | | |
| echo "Weaver branch: ${{ env.BRANCH_NAME }}" | |
| echo "PR target branch (if any): ${{ github.base_ref }}" | |
| echo "Lara framework ref: ${{ steps.repo-refs.outputs.lara_ref }}" | |
| echo "Lara framework default: ${{ steps.repo-refs.outputs.lara_default }}" | |
| echo "Specs-java-libs ref: ${{ steps.repo-refs.outputs.specs_ref }}" | |
| echo "Specs-java-libs default: ${{ steps.repo-refs.outputs.specs_default }}" | |
| - name: Checkout lara-framework | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: specs-feup/lara-framework | |
| path: lara-framework | |
| ref: ${{ steps.repo-refs.outputs.lara_ref }} | |
| - name: Checkout specs-java-libs | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: specs-feup/specs-java-libs | |
| path: specs-java-libs | |
| ref: ${{ steps.repo-refs.outputs.specs_ref }} | |
| - name: Build with Gradle | |
| run: | | |
| cd kadabra/JavaWeaver | |
| gradle installDist | |
| - name: Test with Gradle | |
| run: | | |
| cd kadabra/JavaWeaver | |
| gradle test | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Publish Test Report | |
| uses: mikepenz/action-junit-report@v4 | |
| if: always() | |
| with: | |
| report_paths: "./**/build/test-results/test/TEST-*.xml" | |
| summary: true | |
| - name: Upload JavaWeaver artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: java-binaries | |
| path: kadabra/JavaWeaver/build/install/JavaWeaver | |
| build-js: | |
| name: Build JS | |
| needs: build-java | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| #node-version: ['latest', '22.x', '20.x'] | |
| node-version: ["22.x", "20.x"] | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: ${{ env.JAVA_VERSION }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Checkout Kadabra | |
| uses: actions/checkout@v6 | |
| with: | |
| path: kadabra | |
| - name: Checkout lara-framework | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: specs-feup/lara-framework | |
| path: lara-framework | |
| ref: ${{ needs.build-java.outputs.lara_ref }} | |
| - name: Setup js workspace | |
| run: | | |
| echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "kadabra/Kadabra-JS", "lara-framework/Lara-JS" ] }' > package.json | |
| npm install | |
| - name: Build Lara-JS | |
| run: | | |
| cd lara-framework/Lara-JS | |
| npm run build | |
| - name: Lint TS sources | |
| run: | | |
| cd kadabra/Kadabra-JS | |
| npm run lint | |
| - name: Build Kadabra-JS | |
| run: | | |
| cd kadabra/Kadabra-JS | |
| npm run build | |
| - name: Pull java-binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: java-binaries | |
| path: kadabra/Kadabra-JS/java-binaries | |
| - name: Test JS | |
| run: | | |
| cd kadabra/Kadabra-JS | |
| npm run test |