|
| 1 | +# Copyright (C) 2023 and later: Unicode, Inc. and others. |
| 2 | +# License & terms of use: http://www.unicode.org/copyright.html |
| 3 | +# |
| 4 | +# Note: the workflow here is based on the Github Actions workflow used |
| 5 | +# by the Jekyll theme we are using: |
| 6 | +# https://github.com/just-the-docs/just-the-docs/blob/main/.github/workflows/deploy.yml |
| 7 | +# |
| 8 | +# The Jekyll theme (just-the-docs) configured its Github CI to manually run the Jekyll |
| 9 | +# build instead of relying on the default behavior from |
| 10 | +# https://github.com/actions/jekyll-build-pages . The default behavior of |
| 11 | +# actions/jekyll-build-pages seems to be causing errors with this theme. |
| 12 | +# |
| 13 | +# Also, since the deployment to GitHub Pages is atomic, anything else that touches |
| 14 | +# them should be here. The pattern is: run several jobs, each publishing an artifact, |
| 15 | +# and then the artifacts get merged into one before deploying. |
| 16 | + |
| 17 | +name: Deploy GitHub Pages |
| 18 | + |
| 19 | +on: |
| 20 | + # Runs on pushes targeting the default branch and only if in the `docs/` directory |
| 21 | + push: |
| 22 | + branches: ["main"] |
| 23 | + paths: ["docs/**"] |
| 24 | + |
| 25 | + schedule: |
| 26 | + - cron: '0 2 * * 6' # every Saturday at 2 a.m. |
| 27 | + |
| 28 | + # Allows you to run this workflow manually from the Actions tab |
| 29 | + workflow_dispatch: |
| 30 | + |
| 31 | +env: |
| 32 | + # The _ROOT will become the root of the artifact zip file |
| 33 | + REPORT_ROOT_DIR: '${{ github.workspace }}/artifacts_reports_root' |
| 34 | + # The report folder includes the relative path, matching path we want to see on the generated website. |
| 35 | + # We will generate the reports in the relative folder, so that when we merge the Jekyll generated |
| 36 | + # artifact with the ones from the reports, they all come together where they should. |
| 37 | + REPORT_SITE_RELATIVE_DIR: 'userguide/dev/reports' |
| 38 | + |
| 39 | +permissions: |
| 40 | + contents: read |
| 41 | + |
| 42 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 43 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 44 | +concurrency: |
| 45 | + group: "pages" |
| 46 | + cancel-in-progress: false |
| 47 | + |
| 48 | +jobs: |
| 49 | + # Jekyll build job |
| 50 | + # Keep in sync with docs test workflow in `icu_docs.yml` |
| 51 | + buildsite: |
| 52 | + runs-on: ubuntu-22.04 # Updated in BRS |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 56 | + - name: Setup Ruby |
| 57 | + uses: ruby/setup-ruby@09a7688d3b55cf0e976497ff046b70949eeaccfd # v1.288.0 |
| 58 | + with: |
| 59 | + ruby-version: '2.7.4' # Not needed with a .ruby-version file |
| 60 | + bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 61 | + cache-version: 0 # Increment this number if you need to re-download cached gems |
| 62 | + - name: Setup Pages |
| 63 | + id: pages |
| 64 | + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 |
| 65 | + with: |
| 66 | + generator_config_file: docs/_config.yml |
| 67 | + - name: Build with Jekyll |
| 68 | + # Outputs to the './_site' directory by default |
| 69 | + run: | |
| 70 | + cd docs # root directory of markdown, also contains Jekyll configs, etc. |
| 71 | + bundle install |
| 72 | + # The baseurl arg is parsed from the `baseurl` field of _config.yml. |
| 73 | + bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" |
| 74 | + env: |
| 75 | + JEKYLL_ENV: production |
| 76 | + - name: Upload artifact |
| 77 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 78 | + with: |
| 79 | + name: site-artifact |
| 80 | + path: docs/_site |
| 81 | + retention-days: 3 |
| 82 | + |
| 83 | + # Generate a complete Errorprone report, with all checks enabled, without failing |
| 84 | + errorprone: |
| 85 | + runs-on: ubuntu-22.04 # Updated in BRS |
| 86 | + steps: |
| 87 | + - name: Checkout repo files |
| 88 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 89 | + - name: Set up JDK |
| 90 | + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 91 | + with: |
| 92 | + java-version: '21' |
| 93 | + distribution: 'temurin' |
| 94 | + - name: Run tests with errorprone enabled |
| 95 | + run: mvn clean test -DskipTests -DskipITs -l /tmp/errorprone_all.log -P errorprone-all |
| 96 | + - name: Generate html pages from the errorprone report |
| 97 | + env: |
| 98 | + REPORT_FOLDER_ERRORPRONE: ${{ env.REPORT_ROOT_DIR }}/${{ env.REPORT_SITE_RELATIVE_DIR }}/icu4j_errorprone |
| 99 | + run: | |
| 100 | + mkdir -p ${REPORT_FOLDER_ERRORPRONE} |
| 101 | + mvn exec:java \ |
| 102 | + -f icu4j/tools/build/ \ |
| 103 | + -P errorprone_report \ |
| 104 | + -DlogFile=/tmp/errorprone_all.log \ |
| 105 | + -DoutDir=${REPORT_FOLDER_ERRORPRONE} |
| 106 | + - name: Upload artifact |
| 107 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 108 | + with: |
| 109 | + name: errorprone-artifact |
| 110 | + path: ${{ env.REPORT_ROOT_DIR }} |
| 111 | + retention-days: 3 |
| 112 | + |
| 113 | + # Generate a JaCoCo coverage report |
| 114 | + coverage: |
| 115 | + runs-on: ubuntu-22.04 # Updated in BRS |
| 116 | + steps: |
| 117 | + - name: Checkout repo files |
| 118 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 119 | + - name: Set up JDK |
| 120 | + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
| 121 | + with: |
| 122 | + java-version: '21' |
| 123 | + distribution: 'temurin' |
| 124 | + - name: Run tests with coverage enabled |
| 125 | + run: mvn clean install site site:stage -P coverage |
| 126 | + - name: Setup JaCoCo CLI |
| 127 | + run: | |
| 128 | + rm -fr target/jacoco |
| 129 | + # Download jacoco CLI |
| 130 | + mvn dependency:copy \ |
| 131 | + -Dartifact=org.jacoco:jacoco:LATEST:zip \ |
| 132 | + -DoutputDirectory=target/jacoco \ |
| 133 | + -Dmdep.stripVersion=true \ |
| 134 | + -q -ntp |
| 135 | + unzip -q target/jacoco/jacoco.zip -d target/jacoco |
| 136 | + - name: Generate JaCoCo report merged from all modules |
| 137 | + env: |
| 138 | + REPORT_FOLDER_COVERAGE: ${{ env.REPORT_ROOT_DIR }}/${{ env.REPORT_SITE_RELATIVE_DIR }}/icu4j_coverage |
| 139 | + run: | |
| 140 | + artifact_version="`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`" |
| 141 | + mkdir -p ${REPORT_FOLDER_COVERAGE} |
| 142 | + java -jar target/jacoco/lib/jacococli.jar report \ |
| 143 | + icu4j/main/core/target/jacoco.exec \ |
| 144 | + icu4j/main/collate/target/jacoco.exec \ |
| 145 | + icu4j/main/common_tests/target/jacoco.exec \ |
| 146 | + icu4j/main/framework/target/jacoco.exec \ |
| 147 | + icu4j/main/translit/target/jacoco.exec \ |
| 148 | + icu4j/main/charset/target/jacoco.exec \ |
| 149 | + --classfiles icu4j/main/core/target/core-${artifact_version}.jar \ |
| 150 | + --classfiles icu4j/main/collate/target/collate-${artifact_version}.jar \ |
| 151 | + --classfiles icu4j/main/currdata/target/currdata-${artifact_version}.jar \ |
| 152 | + --classfiles icu4j/main/langdata/target/langdata-${artifact_version}.jar \ |
| 153 | + --classfiles icu4j/main/regiondata/target/regiondata-${artifact_version}.jar \ |
| 154 | + --classfiles icu4j/main/translit/target/translit-${artifact_version}.jar \ |
| 155 | + --classfiles icu4j/main/charset/target/icu4j-charset-${artifact_version}.jar \ |
| 156 | + --sourcefiles icu4j/main/core/src/main/java \ |
| 157 | + --sourcefiles icu4j/main/collate/src/main/java \ |
| 158 | + --sourcefiles icu4j/main/currdata/src/main/java \ |
| 159 | + --sourcefiles icu4j/main/langdata/src/main/java \ |
| 160 | + --sourcefiles icu4j/main/regiondata/src/main/java \ |
| 161 | + --sourcefiles icu4j/main/translit/src/main/java \ |
| 162 | + --sourcefiles icu4j/main/charset/src/main/java \ |
| 163 | + --encoding utf-8 \ |
| 164 | + --csv ${REPORT_FOLDER_COVERAGE}/jacoco.csv \ |
| 165 | + --xml ${REPORT_FOLDER_COVERAGE}/jacoco.xml \ |
| 166 | + --html ${REPORT_FOLDER_COVERAGE}/html |
| 167 | + - name: Upload artifact |
| 168 | + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
| 169 | + with: |
| 170 | + name: coverage-artifact |
| 171 | + path: ${{ env.REPORT_ROOT_DIR }} |
| 172 | + retention-days: 3 |
| 173 | + |
| 174 | + # Merge the artifacts from several jobs into one, for deployment |
| 175 | + merge_artifacts: |
| 176 | + permissions: |
| 177 | + pages: write # to deploy to Pages |
| 178 | + id-token: write # to verify the deployment originates from an appropriate source |
| 179 | + runs-on: ubuntu-22.04 # Updated in BRS |
| 180 | + needs: [buildsite, errorprone, coverage] |
| 181 | + steps: |
| 182 | + - name: Download artifacts |
| 183 | + uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 |
| 184 | + with: # not using a name, so than all artifacts of the run are downloaded, then merged |
| 185 | + path: docs/_site |
| 186 | + merge-multiple: true |
| 187 | + - name: Upload artifact |
| 188 | + uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 |
| 189 | + with: |
| 190 | + path: docs/_site |
| 191 | + retention-days: 3 |
| 192 | + |
| 193 | + # Deployment job |
| 194 | + deploy: |
| 195 | + permissions: |
| 196 | + pages: write # to deploy to Pages |
| 197 | + id-token: write # to verify the deployment originates from an appropriate source |
| 198 | + environment: |
| 199 | + name: github-pages |
| 200 | + url: ${{ steps.deployment.outputs.page_url }} |
| 201 | + runs-on: ubuntu-22.04 # Updated in BRS |
| 202 | + needs: merge_artifacts |
| 203 | + steps: |
| 204 | + - name: Deploy to GitHub Pages |
| 205 | + id: deployment |
| 206 | + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 |
0 commit comments