Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 16 additions & 39 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
on:
workflow_dispatch:
push:
branches: [master, staging]
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .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`
Expand All @@ -41,55 +42,31 @@
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

Check failure on line 54 in .github/workflows/copilot-setup-steps.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=specs-feup_lara-framework&issues=AaBtQk1FH79DEt9I5A6v&open=AaBtQk1FH79DEt9I5A6v&pullRequest=112
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 }}
93 changes: 39 additions & 54 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -27,19 +21,17 @@
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
Expand All @@ -55,27 +47,31 @@
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

Check failure on line 56 in .github/workflows/nightly.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=specs-feup_lara-framework&issues=AaBtQk3VH79DEt9I5A6w&open=AaBtQk3VH79DEt9I5A6w&pullRequest=112
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
Expand Down Expand Up @@ -134,8 +130,8 @@
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 }}

Expand All @@ -153,13 +149,13 @@
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
Expand All @@ -179,26 +175,15 @@
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 }}
- 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 }}
Loading