From 3a149a169eb95ec5f204866690c25c4e49518d59 Mon Sep 17 00:00:00 2001 From: Fred Date: Wed, 27 Nov 2024 17:56:24 -0300 Subject: [PATCH 1/2] chore: remove antora file and improve doc CI --- .../scripts/update-antora-configuration.sh | 11 ++++ .github/workflows/pull_request_secure.yml | 59 ++++++++++++++++--- docs/src/antora.yml | 19 ------ 3 files changed, 61 insertions(+), 28 deletions(-) create mode 100755 .github/scripts/update-antora-configuration.sh delete mode 100644 docs/src/antora.yml diff --git a/.github/scripts/update-antora-configuration.sh b/.github/scripts/update-antora-configuration.sh new file mode 100755 index 0000000000..7751e87c48 --- /dev/null +++ b/.github/scripts/update-antora-configuration.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +sed -i "s/\${project\.version}b0/$LATEST_VERSION/g" $1 +sed -i "s/\${project\.version}/$LATEST_VERSION/g" $1 +sed -i "s/\${maven\.compiler\.release}/$JAVA_VERSION/g" $1 +sed -i "s/\${maven\.min\.version}/$MAVEN_VERSION/g" $1 +sed -i "s/\${version\.io\.quarkus}/$QUARKUS_VERSION/g" $1 +sed -i "s/\${version\.org\.springframework\.boot}/$SPRING_VERSION/g" $1 +sed -i "s/\${version\.ch\.qos\.logback}/$LOGBACK_VERSION/g" $1 +sed -i "s/\${version\.exec\.plugin}/$EXEC_MAVEN_VERSION/g" $1 +sed -i "s/\${version\.rewrite\.plugin}/$REWRITE_PLUGIN_VERSION/g" $1 \ No newline at end of file diff --git a/.github/workflows/pull_request_secure.yml b/.github/workflows/pull_request_secure.yml index cf7849a3ac..1d123faea6 100644 --- a/.github/workflows/pull_request_secure.yml +++ b/.github/workflows/pull_request_secure.yml @@ -6,13 +6,13 @@ name: Secured Workflow on: push: - branches: [main] + branches: [ main ] # There are two differences to "pull_request" here: # - The workflow will receive secrets, even in PRs from forks. # - The workflow will be executed automatically, without requiring a manual approval. # Therefore the workflow needs to be explicitly secured; see "known_user" and "approval_required" jobs below. pull_request_target: - branches: [main] # Benchmarks aren't branched, so they will only ever work against current main. + branches: [ main ] # Benchmarks aren't branched, so they will only ever work against current main. types: - opened - reopened @@ -266,13 +266,7 @@ jobs: name: Build Documentation env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - GURL: "https://github.com/${{ github.event.pull_request.head.repo.owner.login || 'TimefoldAI' }}/timefold-solver" steps: - - name: Install yq - run: | - sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq - sudo chmod +x /usr/bin/yq - - name: Checkout frontend id: checkout-frontend uses: actions/checkout@v4 @@ -287,13 +281,60 @@ jobs: node-version-file: .nvmrc cache: npm + - name: Checkout timefold-solver + uses: actions/checkout@v4 + with: + repository: "${{ github.event.pull_request.head.repo.owner.login || 'TimefoldAI' }}/timefold-solver" + ref: ${{ github.event.pull_request.head.sha || 'main' }} # The GHA event will pull the main branch by default, and we must specify the PR reference version + path: "./timefold-solver" + fetch-depth: 0 + + - name: Install yq + run: | + sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq + sudo chmod +x /usr/bin/yq + + - name: Configuring Antora version + working-directory: "./timefold-solver" + run: | + LATEST_VERSION="SNAPSHOT" + echo "LATEST_VERSION=$LATEST_VERSION" >> "$GITHUB_ENV" + LATEST_DATE="$(date +"%F")" + echo "LATEST_DATE=$LATEST_DATE" >> "$GITHUB_ENV" + JAVA_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "JAVA_VERSION=$JAVA_VERSION" >> "$GITHUB_ENV" + MAVEN_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "MAVEN_VERSION=$MAVEN_VERSION" >> "$GITHUB_ENV" + QUARKUS_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "QUARKUS_VERSION=$QUARKUS_VERSION" >> "$GITHUB_ENV" + SPRING_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "SPRING_VERSION=$SPRING_VERSION" >> "$GITHUB_ENV" + LOGBACK_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "LOGBACK_VERSION=$LOGBACK_VERSION" >> "$GITHUB_ENV" + EXEC_MAVEN_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "EXEC_MAVEN_VERSION=$EXEC_MAVEN_VERSION" >> "$GITHUB_ENV" + REWRITE_PLUGIN_VERSION="$(find . -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" + echo "REWRITE_PLUGIN_VERSION=$REWRITE_PLUGIN_VERSION" >> "$GITHUB_ENV" + echo "=== Resulting environment variables:" + cat $GITHUB_ENV + echo "=== End of environment variables." + + - name: Updating Antora configuration + working-directory: "./timefold-solver" + run: | + echo "=== Updating antora.yml" + cp docs/src/antora-template.yml docs/src/antora.yml + sh .github/scripts/update-antora-configuration.sh docs/src/antora.yml + cat docs/src/antora.yml + - name: Build Documentation + working-directory: "./" env: GIT_CREDENTIALS: ${{ secrets.GIT_CREDENTIALS }} run: | yq -i e 'del(.content.sources)' apps/docs/antora-playbook.yml yq -i e 'del(.site.keys)' apps/docs/antora-playbook.yml - yq -i e '.content.sources += [{"url": env(GURL), "branches": env(BRANCH_NAME), "start_path": "docs/src"}]' apps/docs/antora-playbook.yml + yq -i e '.content.sources += [{"url": "../../timefold-solver", "start_path": "docs/src"}]' apps/docs/antora-playbook.yml npm ci npm run build -- --filter docs diff --git a/docs/src/antora.yml b/docs/src/antora.yml deleted file mode 100644 index 295e0e9daf..0000000000 --- a/docs/src/antora.yml +++ /dev/null @@ -1,19 +0,0 @@ -# This file is temporary, since for the time being, we need to build docs from the main branch. -# Remove when 1.16.0 is out, otherwise this file quickly becomes stale. -name: timefold-solver -title: Timefold Solver 1.15.0 -version: latest -asciidoc: - attributes: - timefold-solver-version: 1.15.0 - timefold-solver-python-version: 1.15.0b0 - java-version: 17 - maven-version: 3.9.2 - python-version: '3.10' - quarkus-version: 3.15.1 - spring-boot-version: 3.3.5 - logback-version: 1.5.12 - exec-maven-plugin-version: 3.3.1 - rewrite-maven-plugin-version: 5.43.4 -nav: - - modules/ROOT/nav.adoc \ No newline at end of file From 7012fbf258896867096c53dc2e564d0ca58b3294 Mon Sep 17 00:00:00 2001 From: Fred Date: Wed, 27 Nov 2024 21:36:18 -0300 Subject: [PATCH 2/2] chore: address comments --- .../scripts/update-antora-configuration.sh | 11 ------ .github/workflows/pull_request_secure.yml | 35 +++++-------------- 2 files changed, 9 insertions(+), 37 deletions(-) delete mode 100755 .github/scripts/update-antora-configuration.sh diff --git a/.github/scripts/update-antora-configuration.sh b/.github/scripts/update-antora-configuration.sh deleted file mode 100755 index 7751e87c48..0000000000 --- a/.github/scripts/update-antora-configuration.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -sed -i "s/\${project\.version}b0/$LATEST_VERSION/g" $1 -sed -i "s/\${project\.version}/$LATEST_VERSION/g" $1 -sed -i "s/\${maven\.compiler\.release}/$JAVA_VERSION/g" $1 -sed -i "s/\${maven\.min\.version}/$MAVEN_VERSION/g" $1 -sed -i "s/\${version\.io\.quarkus}/$QUARKUS_VERSION/g" $1 -sed -i "s/\${version\.org\.springframework\.boot}/$SPRING_VERSION/g" $1 -sed -i "s/\${version\.ch\.qos\.logback}/$LOGBACK_VERSION/g" $1 -sed -i "s/\${version\.exec\.plugin}/$EXEC_MAVEN_VERSION/g" $1 -sed -i "s/\${version\.rewrite\.plugin}/$REWRITE_PLUGIN_VERSION/g" $1 \ No newline at end of file diff --git a/.github/workflows/pull_request_secure.yml b/.github/workflows/pull_request_secure.yml index 1d123faea6..720f8abd3f 100644 --- a/.github/workflows/pull_request_secure.yml +++ b/.github/workflows/pull_request_secure.yml @@ -294,37 +294,20 @@ jobs: sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq sudo chmod +x /usr/bin/yq - - name: Configuring Antora version - working-directory: "./timefold-solver" - run: | - LATEST_VERSION="SNAPSHOT" - echo "LATEST_VERSION=$LATEST_VERSION" >> "$GITHUB_ENV" - LATEST_DATE="$(date +"%F")" - echo "LATEST_DATE=$LATEST_DATE" >> "$GITHUB_ENV" - JAVA_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "JAVA_VERSION=$JAVA_VERSION" >> "$GITHUB_ENV" - MAVEN_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "MAVEN_VERSION=$MAVEN_VERSION" >> "$GITHUB_ENV" - QUARKUS_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "QUARKUS_VERSION=$QUARKUS_VERSION" >> "$GITHUB_ENV" - SPRING_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "SPRING_VERSION=$SPRING_VERSION" >> "$GITHUB_ENV" - LOGBACK_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "LOGBACK_VERSION=$LOGBACK_VERSION" >> "$GITHUB_ENV" - EXEC_MAVEN_VERSION="$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "EXEC_MAVEN_VERSION=$EXEC_MAVEN_VERSION" >> "$GITHUB_ENV" - REWRITE_PLUGIN_VERSION="$(find . -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)" - echo "REWRITE_PLUGIN_VERSION=$REWRITE_PLUGIN_VERSION" >> "$GITHUB_ENV" - echo "=== Resulting environment variables:" - cat $GITHUB_ENV - echo "=== End of environment variables." - - name: Updating Antora configuration working-directory: "./timefold-solver" run: | echo "=== Updating antora.yml" cp docs/src/antora-template.yml docs/src/antora.yml - sh .github/scripts/update-antora-configuration.sh docs/src/antora.yml + sed -i "s/\${project\.version}b0/SNAPSHOT/g" docs/src/antora.yml + sed -i "s/\${project\.version}/SNAPSHOT/g" docs/src/antora.yml + sed -i "s/\${maven\.compiler\.release}/$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)/g" docs/src/antora.yml + sed -i "s/\${maven\.min\.version}/$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)/g" docs/src/antora.yml + sed -i "s/\${version\.io\.quarkus}/$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)/g" docs/src/antora.yml + sed -i "s/\${version\.org\.springframework\.boot}/$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)N/g" docs/src/antora.yml + sed -i "s/\${version\.ch\.qos\.logback}/$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)/g" docs/src/antora.yml + sed -i "s/\${version\.exec\.plugin}/$(find build/build-parent/ -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)/g" docs/src/antora.yml + sed -i "s/\${version\.rewrite\.plugin}/$(find . -name pom.xml -exec grep '' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)/g" docs/src/antora.yml cat docs/src/antora.yml - name: Build Documentation