diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 4b3da327d..806e52a48 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: @@ -14,7 +15,7 @@ on: - .github/workflows/copilot-setup-steps.yml env: - LARA_FRAMEWORK_BRANCH: ${{ github.head_ref || github.ref_name }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} jobs: # The job MUST be called `copilot-setup-steps` @@ -41,55 +42,31 @@ jobs: uses: gradle/actions/setup-gradle@v4 with: gradle-version: current - dependency-graph: generate-and-submit - name: Checkout lara-framework - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: lara-framework + 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.LARA_FRAMEWORK_BRANCH }} - run: | - set -euo pipefail - - determine_ref() { - local prefix=$1 - local repo=$2 - local url="https://github.com/${repo}.git" - - 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}'" - - if git ls-remote --heads "$url" "refs/heads/${BRANCH_NAME}" >/dev/null; then - echo "${prefix}_match=true" >> "$GITHUB_OUTPUT" - echo "${prefix}_ref=${BRANCH_NAME}" >> "$GITHUB_OUTPUT" - echo "Branch '${BRANCH_NAME}' exists in ${repo}" - else - echo "${prefix}_match=false" >> "$GITHUB_OUTPUT" - echo "${prefix}_ref=${default_branch}" >> "$GITHUB_OUTPUT" - echo "Branch '${BRANCH_NAME}' not found in ${repo}. Falling back to '${default_branch}'." - fi - } - - determine_ref "specs" "specs-feup/specs-java-libs" + uses: specs-feup/branch-resolver@v1 + with: + source-directory: lara-framework + evidence-repositories: specs-feup/clava + dependencies: specs specs-feup/specs-java-libs - name: Echo checks run: | - echo "Lara-Framework branch: ${{ env.LARA_FRAMEWORK_BRANCH }}" - echo "Matching branch found (specs-java-libs): ${{ steps.repo-refs.outputs.specs_match }}" - echo "Specs-java-libs ref: ${{ steps.repo-refs.outputs.specs_ref }}" - echo "Specs-java-libs default fallback: ${{ steps.repo-refs.outputs.specs_default }}" - echo "Pull request base_ref (if any): ${{ github.base_ref }}" + echo "Lara branch: ${{ env.BRANCH_NAME }}" + 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 specs-java-libs - uses: actions/checkout@v4 + 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 }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1a64a69ca..663a9d5e5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,24 +1,18 @@ # 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: - branches: - - master - - staging - + # 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: - branches: - - master - - staging - # Weekly on Mondays early morning + # Daily at midnight schedule: - - cron: '23 3 * * 1' + - cron: '0 0 * * *' permissions: checks: write @@ -27,19 +21,17 @@ permissions: env: JAVA_VERSION: 17 BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - # Setting default branch to staging assuming PRs will be done against the staging versions of the repository - # main versions will just receive what comes from the staging - DEFAULT_BRANCH: ${{ github.base_ref || 'staging' }} - #SPECS_JAVA_LIBS_BRANCH: ${{ 'master' }} - #LARA_FRAMEWORK_BRANCH: ${{ github.head_ref || github.ref_name }} 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: - branch-exists-specs-java-libs: ${{ steps.Branch-specs-java-libs.outputs.value }} + specs_ref: ${{ env.specs_ref }} steps: - name: Setup Java @@ -55,27 +47,31 @@ jobs: dependency-graph: generate-and-submit - name: Checkout lara-framework - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: lara-framework + fetch-depth: 0 - - name: Check if branch exists on specs-java-libs - id: Branch-specs-java-libs - run: echo "value=$(git ls-remote --heads https://github.com/specs-feup/specs-java-libs.git refs/heads/${{ env.BRANCH_NAME }} | wc -l)" >> $GITHUB_OUTPUT + - name: Determine repository refs + uses: specs-feup/branch-resolver@v1 + with: + source-directory: lara-framework + evidence-repositories: specs-feup/clava + dependencies: specs specs-feup/specs-java-libs - name: Echo checks run: | - echo "Branch-specs-java-libs: ${{ steps.Branch-specs-java-libs.outputs.value }}" - echo "Branch name: ${{ env.BRANCH_NAME }}" - echo "Default branch: ${{ env.DEFAULT_BRANCH }}" - echo "Branch base_ref: ${{ github.base_ref }}" + echo "Lara branch: ${{ env.BRANCH_NAME }}" + 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 specs-java-libs - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: specs-feup/specs-java-libs path: specs-java-libs - ref: ${{ steps.Branch-specs-java-libs.outputs.value == '1' && env.BRANCH_NAME || env.DEFAULT_BRANCH }} + ref: ${{ env.specs_ref }} # Setting up gradle multi-project would be helpful - name: Build and test LanguageSpecification @@ -134,8 +130,8 @@ jobs: strategy: fail-fast: false matrix: - node-version: ['22.x'] - os: [ubuntu-latest, windows-2022, macos-latest] + node-version: ['25.x', '24.x'] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} @@ -153,13 +149,13 @@ jobs: registry-url: 'https://registry.npmjs.org/' - name: Checkout lara-framework - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: lara-framework - name: Setup js workspace run: | - echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "lara-framework/Lara-JS" ] }' > package.json + echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "lara-framework/Lara-JS" ], "overrides": { "node-gyp": "^12.1.0" } }' > package.json npm install - name: Build Lara-JS @@ -179,26 +175,15 @@ jobs: npm run test # Only on ubuntu-latest - #- name: Publish JS - # if: matrix.os == 'ubuntu-latest' && matrix.node-version == '22.x' - # run: | - # cd lara-framework/Lara-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 - # 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 - # env: - # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + - name: Publish JS + if: github.event_name == 'push' && github.ref == 'refs/heads/staging' && matrix.os == 'ubuntu-latest' && matrix.node-version == '25.x' + run: | + cd lara-framework/Lara-JS + npm whoami + echo "Attempt to publish while running on ${{ matrix.os }} and Node.js ${{matrix.node-version}}" + 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 }}