nightly #638
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: | |
| push: | |
| # Daily at midnight | |
| schedule: | |
| - cron: '0 0 * * *' | |
| permissions: | |
| checks: write | |
| contents: write | |
| 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 | |
| runs-on: ubuntu-latest | |
| outputs: | |
| branch-exists-specs-java-libs: ${{ steps.Branch-specs-java-libs.outputs.value }} | |
| 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 lara-framework | |
| uses: actions/checkout@v4 | |
| with: | |
| path: lara-framework | |
| - 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: 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 }}" | |
| - name: Checkout specs-java-libs | |
| uses: actions/checkout@v4 | |
| 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 }} | |
| # Setting up gradle multi-project would be helpful | |
| - name: Build and test LanguageSpecification | |
| working-directory: lara-framework/LanguageSpecification | |
| run: gradle build test | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Build and test LARAI | |
| working-directory: lara-framework/LARAI | |
| run: gradle build test | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Build and test LaraUtils | |
| working-directory: lara-framework/LaraUtils | |
| run: gradle build test | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Build and test WeaverInterface | |
| working-directory: lara-framework/WeaverInterface | |
| run: gradle build test | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Build and test WeaverGenerator | |
| working-directory: lara-framework/WeaverGenerator | |
| run: gradle build test | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Build and test DefaultWeaver | |
| working-directory: lara-framework/DefaultWeaver | |
| run: gradle installDist | |
| env: | |
| GITHUB_DEPENDENCY_GRAPH_ENABLED: false | |
| - name: Build and test WeaverOptionsManager | |
| working-directory: lara-framework/WeaverOptionsManager | |
| run: gradle build 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 java binary artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: java-binaries | |
| path: lara-framework/DefaultWeaver/build/install/DefaultWeaver | |
| 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 }} | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Checkout lara-framework | |
| uses: actions/checkout@v4 | |
| with: | |
| path: lara-framework | |
| - name: Setup js workspace | |
| run: | | |
| echo '{ "name": "SPeCS Workspace", "type": "module", "workspaces": [ "lara-framework/Lara-JS" ] }' > package.json | |
| npm install | |
| - name: Build Lara-JS | |
| run: | | |
| cd lara-framework/Lara-JS | |
| npm run build | |
| - name: Pull java binary artifacts from previous job | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: java-binaries | |
| path: lara-framework/DefaultWeaver/build/install/DefaultWeaver | |
| - name: Test JS | |
| run: | | |
| cd lara-framework/Lara-JS | |
| 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 }} |