diff --git a/.github/workflows/ant-lara-2.0-legacy.yml b/.github/workflows/ant-lara-2.0-legacy.yml index 7cbc13cfc..bc3ba08dc 100644 --- a/.github/workflows/ant-lara-2.0-legacy.yml +++ b/.github/workflows/ant-lara-2.0-legacy.yml @@ -50,7 +50,7 @@ jobs: - name: Generate build.xml run: | wget -q -N http://specs.fe.up.pt/tools/eclipse-build.jar - java -jar eclipse-build.jar https://github.com/specs-feup/specs-java-libs https://github.com/specs-feup/lara-framework?commit=lara-2.0-legacy ./ + java -jar eclipse-build.jar https://github.com/specs-feup/specs-java-libs?commit=lara-2.0-legacy https://github.com/specs-feup/lara-framework?commit=lara-2.0-legacy ./ wget -N -O /usr/share/ant/lib/ivy-2.5.0.jar specs.fe.up.pt/libs/ivy-2.5.0.jar - name: Build with Ant run: | diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 41776a2df..93c29172c 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -7,6 +7,7 @@ name: "Copilot Setup Steps" on: workflow_dispatch: push: + branches: [master, staging] paths: - .github/workflows/copilot-setup-steps.yml pull_request: @@ -46,74 +47,63 @@ jobs: uses: actions/checkout@v6 with: path: clava + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha || github.sha }} - 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" + uses: specs-feup/branch-resolver@v1 + with: + source-directory: clava + dependencies: | + lara specs-feup/lara-framework + 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 }}" + echo "Lara framework branch: ${{ env.lara_branch }}" + echo "Lara framework commit: ${{ env.lara_ref }}" + echo "Lara framework default: ${{ env.lara_default }}" + echo "Specs-java-libs branch: ${{ env.specs_branch }}" + echo "Specs-java-libs commit: ${{ env.specs_ref }}" + echo "Specs-java-libs default: ${{ env.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 }} + ref: ${{ env.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 }} + ref: ${{ env.specs_ref }} + + - name: Build Weaver + run: | + cd clava/ClavaWeaver + gradle installDist + + - name: Setup java-binaries symlink + run: | + cd clava/Clava-JS + ln -s ../ClavaWeaver/build/install/ClavaWeaver/ java-binaries + + + - name: Setup JS workspace + run: | + echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "clava/Clava-JS", "lara-framework/Lara-JS" ] }' > package.json + npm install + + - name: Build Lara-JS + run: | + cd lara-framework/Lara-JS + npm run build + + - name: Build Clava-JS + run: | + cd clava/Clava-JS + npm run build diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5bdba30cd..aa8c73105 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,11 +1,13 @@ # 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: + # No pull_request trigger: GitHub refuses to build the merge ref for + # conflicted PRs, which would suppress the CI signal entirely. Push runs + # on the branch tip report checks to the PR's Checks tab all the same. push: # Daily at midnight @@ -23,11 +25,14 @@ env: jobs: build-java: name: Build Java + # On branch deletion GitHub reports the default branch's SHA; building + # that event would mislead the branch resolver. + if: github.event.deleted != true runs-on: ubuntu-latest outputs: - lara_ref: ${{ steps.repo-refs.outputs.lara_ref }} - specs_ref: ${{ steps.repo-refs.outputs.specs_ref }} + lara_ref: ${{ env.lara_ref }} + specs_ref: ${{ env.specs_ref }} steps: - name: Setup Java @@ -46,77 +51,39 @@ jobs: uses: actions/checkout@v6 with: path: clava + fetch-depth: 0 - 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" + uses: specs-feup/branch-resolver@v1 + with: + source-directory: clava + dependencies: | + lara specs-feup/lara-framework + 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 }}" + echo "Lara framework branch: ${{ env.lara_branch }}" + echo "Lara framework commit: ${{ env.lara_ref }}" + echo "Lara framework default: ${{ env.lara_default }}" + echo "Specs-java-libs branch: ${{ env.specs_branch }}" + echo "Specs-java-libs commit: ${{ env.specs_ref }}" + echo "Specs-java-libs default: ${{ env.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 }} + ref: ${{ env.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 }} + ref: ${{ env.specs_ref }} - name: Build with Gradle run: | @@ -156,7 +123,7 @@ jobs: fail-fast: false matrix: #node-version: ['latest', '22.x', '20.x'] - node-version: ['22.x', '20.x'] + node-version: ['25.x', '24.x'] os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} @@ -197,7 +164,7 @@ jobs: - name: Setup js workspace run: | - echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "clava/Clava-JS", "lara-framework/Lara-JS" ] }' > package.json + echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "clava/Clava-JS", "lara-framework/Lara-JS" ], "overrides": { "node-gyp": "^12.1.0" } }' > package.json npm install - name: Build Lara-JS @@ -223,26 +190,14 @@ jobs: # Only on ubuntu-latest - name: Publish JS - if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' + if: github.event_name == 'push' && github.ref == 'refs/heads/staging' && matrix.os == 'ubuntu-latest' && matrix.node-version == '25.x' run: | cd clava/Clava-JS npm whoami echo "Attempt to publish while running on ${{ matrix.os }} and Node.js ${{matrix.node-version}}" - if [[ "${{ github.event_name }}" == "push" ]]; then - if [ "${{ github.ref }}" == "refs/heads/staging" ]; then - echo "Publishing from staging, creating timestamped prerelease and updating tag 'staging'" - TIMESTAMP=$(date +"%Y%m%d%H%M") - npm version prerelease --preid="$TIMESTAMP" - npm publish --tag staging --access public - # Not updating automatically the version since this would make the staging branch diverge from the main branch - #elif [ "${{ github.ref }}" == "refs/heads/master" ]; then - # echo "Publishing from main, assumes version was changed before publishing" - # npm publish - else - echo "Not master or staging branches, not publishing even if it is a push event" - fi - else - echo "Not a push event, skipping publish." - fi + echo "Publishing from staging, creating timestamped prerelease and updating tag 'staging'" + TIMESTAMP=$(date +"%Y%m%d%H%M") + npm version prerelease --preid="$TIMESTAMP" + npm publish --tag staging --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/Clava-JS/package.json b/Clava-JS/package.json index b15575ecc..1c253d8ed 100644 --- a/Clava-JS/package.json +++ b/Clava-JS/package.json @@ -1,6 +1,6 @@ { "name": "@specs-feup/clava", - "version": "3.5.0", + "version": "3.5.1", "description": "A C/C++ source-to-source compiler written in Typescript", "type": "module", "files": [