Skip to content

02-gh-pages-rebuild-part-1 #6

02-gh-pages-rebuild-part-1

02-gh-pages-rebuild-part-1 #6

name: "02-gh-pages-rebuild-part-1" # Note: workflow name is used on workflow 04
on:
workflow_dispatch:
env:
GH_TOKEN: ${{ github.token }}
permissions:
contents: write
pages: write
id-token: write
pull-requests: read
jobs:
initialize:
name: Build Basic Site
runs-on: ubuntu-latest
outputs:
pull_requests: ${{ steps.get-prs.outputs.pull_requests }}
steps:
- name: Checkout local code to establish repo
uses: actions/checkout@v4
- name: Get Pull Requests from Github api
id: get-prs
run: |
gh pr list -s open --json url,author,number,title,headRefName
gh pr list -s open --json url,author,number,title,headRefName > prs.json
cat prs.json
pull_requests=`cat prs.json`
echo "pull_requests=${pull_requests}"
echo "pull_requests=${pull_requests}" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
build-javadoc-main:
name: a - Javadoc (main)
runs-on: ubuntu-latest
needs: [initialize]
env:
destination: target/site/apidocs
steps:
- name: Checkout local code to establish repo
uses: actions/checkout@v4
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v4
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: Build javadoc
run: mvn -DskipTests javadoc:javadoc
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: javadoc
path: ${{ env.destination }}
overwrite: true
build-chromatic-main:
name: b - Chromatic (main)
runs-on: ubuntu-latest
needs: [initialize]
env:
destination: frontend/chromatic_static
steps:
- name: Checkout local code to establish repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Chromatic needs the full git history
token: ${{ github.token }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
# ⚠️ See your package manager's documentation for the correct command to install dependencies in a CI environment.
run: npm ci
- name: Run Chromatic
id: run_chromatic
uses: chromaui/action@latest
with:
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: frontend
- name: Echo output
run: |
echo "Chromatic URL: ${{ steps.run_chromatic.outputs.url }}"
echo "Chromatic build ID: ${{ steps.run_chromatic.outputs.storybookUrl }}"
- name: Build redirect file
working-directory: frontend
run: | # Create a redirect file to redirect to the storybook online
mkdir -p chromatic_static
echo "<meta http-equiv=refresh content=0;url=${{steps.run_chromatic.outputs.storybookUrl}}>" > chromatic_static/index.html
echo "<meta http-equiv=refresh content=0;url=${{steps.run_chromatic.outputs.url}}>" > chromatic_static/build.html
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: chromatic
path: ${{ env.destination }}
overwrite: true
build-jacoco-main:
name: c - Jacoco (main)
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [initialize]
env:
destination: target/site/jacoco
steps:
- uses: actions/checkout@v4
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v4
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: Build with Maven
continue-on-error: true
env:
TEST_PROPERTIES: ${{ secrets.TEST_PROPERTIES }}
run: mvn -B test jacoco:report verify
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: jacoco
path: ${{ env.destination }}
overwrite: true
build-pitest-main:
name: d - Pitest (main)
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [initialize]
env:
destination: target/pit-reports
history_destination: target/pit-history
steps:
- uses: actions/checkout@v4
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v4
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: create directories
run: |
mkdir -p ${{ env.destination }}
mkdir -p ${{ env.history_destination }}
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: 02-gh-pages-rebuild-part-1.yml
github_token: ${{secrets.GITHUB_TOKEN}}
branch: ${{ env.branch_name }}
name: pitest-main-history.bin
path: ${{ env.history_destination}}
check_artifacts: true
if_no_artifact_found: warn
- name: Copy artifact to pit-history/history.bin # specified in pom.xml as historyInputFile
continue-on-error: true
run: |
historyFile=${{ env.history_destination}}/pitest-main-history.bin
if [ -f "$historyFile" ] ; then
cp $historyFile ${{ env.history_destination}}/history.bin
fi
- name: Build with Maven
continue-on-error: true
env:
TEST_PROPERTIES: ${{ secrets.TEST_PROPERTIES }}
run: mvn test pitest:mutationCoverage -DmutationThreshold=100
- name: Upload Pitest History to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v4
with:
name: pitest-main-history.bin
path: ${{ env.history_destination}}/history.bin
overwrite: true
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: pitest
path: ${{ env.destination }}
overwrite: true
build-coverage-main:
name: e - Coverage (main)
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [initialize]
env:
destination: frontend/coverage/lcov-report
steps:
- uses: szenius/set-timezone@v2.0
with:
timezoneLinux: "America/Los_Angeles"
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- run: npm ci
working-directory: ./frontend
- run: npm run coverage
continue-on-error: true
working-directory: ./frontend
- name: Upload jest coverage report to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v4
with:
name: coverage
path: ${{ env.destination }}
overwrite: true
build-stryker-main:
name: f - Stryker (main)
runs-on: ubuntu-latest
timeout-minutes: 60
needs: [initialize]
steps:
- uses: szenius/set-timezone@v2.0
with:
timezoneLinux: "America/Los_Angeles"
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: npm clean install, and create directories
working-directory: ./frontend
run: |
npm ci
mkdir -p history
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: 02-gh-pages-rebuild-part-1.yml
github_token: ${{secrets.GITHUB_TOKEN}}
branch: main
name: stryker-incremental-main.json
path: frontend/history
check_artifacts: true
if_no_artifact_found: warn
- name: Stryker (main, incremental)
working-directory: ./frontend
continue-on-error: true
run: |
npx stryker run --incremental --incrementalFile history/stryker-incremental-main.json
- name: Upload stryker incremental file to Artifacts
uses: actions/upload-artifact@v4
with:
name: stryker-incremental-main.json
path: frontend/history
overwrite: true
- name: Upload report to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v4
with:
name: stryker
path: frontend/reports/mutation/mutation.html
overwrite: true
a-build-javadoc-for-each-pr:
name: a - Javadoc (${{ matrix.value.number }}, ${{ matrix.value.headRefName }})
runs-on: ubuntu-latest
if: ${{ needs.initialize.outputs.pull_requests != '[]' && needs.initialize.outputs.pull_requests != '' }}
needs: [initialize]
env:
destination: target/site/apidocs
strategy:
matrix:
value: ${{ fromJSON(needs.initialize.outputs.pull_requests)}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.value.headRefName }}
fetch-depth: 1
token: ${{ github.token }}
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v4
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: Build javadoc
run: mvn -DskipTests javadoc:javadoc
- name: Upload javadoc to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v4
with:
name: prs-${{ matrix.value.number }}-javadoc
path: ${{ env.destination }}
overwrite: true
b-build-chromatic-for-each-pr:
name: b - Chromatic (${{ matrix.value.number }}, ${{ matrix.value.headRefName }})
runs-on: ubuntu-latest
needs: [initialize]
if: ${{ needs.initialize.outputs.pull_requests != '[]' && needs.initialize.outputs.pull_requests != '' }}
env:
destination: prs/${{ matrix.value.number }}/chromatic
strategy:
matrix:
value: ${{ fromJSON(needs.initialize.outputs.pull_requests)}}
steps:
- name: Debugging Output
run: |
echo "matrix.value: ${{ matrix.value }}"
echo "matrix.value.url: ${{ matrix.value.url }}"
echo "matrix.value.author: ${{ matrix.value.author }}"
echo "matrix.value.number: ${{ matrix.value.number }}"
echo "matrix.value.title: ${{ matrix.value.title }}"
echo "matrix.value.headRefName: ${{ matrix.value.headRefName }}"
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.value.headRefName }}
fetch-depth: 0 # Chromatic needs the full git history
token: ${{ github.token }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci
- name: Run Chromatic
id: run_chromatic
uses: chromaui/action@latest
with:
# ⚠️ Make sure to configure a `CHROMATIC_PROJECT_TOKEN` repository secret
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
workingDir: frontend
- name: Echo output
run: |
echo "Chromatic URL: ${{ steps.run_chromatic.outputs.url }}"
echo "Chromatic build ID: ${{ steps.run_chromatic.outputs.storybookUrl }}"
- name: Build redirect files
working-directory: frontend
run: | # Create redirect files to redirect to the storybook online
mkdir -p ${{ env.destination }}
echo "<meta http-equiv=refresh content=0;url=${{steps.run_chromatic.outputs.storybookUrl}}>" > ${{ env.destination }}/index.html
echo "<meta http-equiv=refresh content=0;url=${{steps.run_chromatic.outputs.url}}>" > ${{ env.destination }}/build.html
- name: Upload Chromatic to artifacts
uses: actions/upload-artifact@v4
with:
name: prs-${{ matrix.value.number }}-chromatic
path: ${{ env.destination }}
overwrite: true
c-build-jacoco-for-each-pr:
name: c - Jacoco (${{ matrix.value.number }}, ${{ matrix.value.headRefName }})
runs-on: ubuntu-latest
if: ${{ needs.initialize.outputs.pull_requests != '[]' && needs.initialize.outputs.pull_requests != '' }}
needs: [initialize]
strategy:
matrix:
value: ${{ fromJSON(needs.initialize.outputs.pull_requests)}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.value.headRefName }}
fetch-depth: 1
token: ${{ github.token }}
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v4
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: Build with Maven
continue-on-error: true
env:
TEST_PROPERTIES: ${{ secrets.TEST_PROPERTIES }}
run: mvn -B test jacoco:report verify
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: prs-${{ matrix.value.number }}-jacoco
path: target/site/jacoco
overwrite: true
d-build-pitest-for-each-pr:
name: d - Pitest (${{ matrix.value.number }}, ${{ matrix.value.headRefName }})
runs-on: ubuntu-latest
if: ${{ needs.initialize.outputs.pull_requests != '[]' && needs.initialize.outputs.pull_requests != '' }}
needs: [initialize]
env:
destination: target/pit-reports
history_destination: target/pit-history
strategy:
matrix:
value: ${{ fromJSON(needs.initialize.outputs.pull_requests)}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.value.headRefName }}
fetch-depth: 1
token: ${{ github.token }}
- name: create directories
run: |
mkdir -p ${{ env.destination }}
mkdir -p ${{ env.history_destination }}
- name: Figure out branch name
id: get-branch-name
run: |
BRANCH=$(echo "${{ matrix.value.headRefName }}" | sed 's/refs\/heads\///g')
echo "branch_name=${BRANCH}"
echo "branch_name=${BRANCH}" >> "$GITHUB_ENV"
- name: Set up Java (version from .java-version file)
uses: actions/setup-java@v4
with:
distribution: semeru # See: https://github.com/actions/setup-java#supported-distributions
java-version-file: ./.java-version
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: 02-gh-pages-rebuild-part-1.yml
github_token: ${{secrets.GITHUB_TOKEN}}
branch: ${{ env.branch_name }}
name: pitest-${{ matrix.value.number }}-history.bin
path: ${{ env.history_destination}}
check_artifacts: true
if_no_artifact_found: warn
- name: Debugging output before mvn pitest ...
run: |
ls -lRt target
- name: Build with Maven
continue-on-error: true
env:
TEST_PROPERTIES: ${{ secrets.TEST_PROPERTIES }}
run: mvn test pitest:mutationCoverage -DmutationThreshold=100
- name: Debugging output after mvn pitest ...
run: |
ls -lRt target
- name: Upload Pitest History to Artifacts
if: always() # always upload artifacts, even if tests fail
uses: actions/upload-artifact@v4
with:
name: pitest-${{ matrix.value.number }}-history.bin
path: ${{ env.history_destination}}/history.bin
overwrite: true
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: prs-${{ matrix.value.number }}-pitest
path: ${{ env.destination }}
overwrite: true
e-build-coverage-for-each-pr:
name: e - Coverage (${{ matrix.value.number }}, ${{ matrix.value.headRefName }})
runs-on: ubuntu-latest
if: ${{ needs.initialize.outputs.pull_requests != '[]' && needs.initialize.outputs.pull_requests != '' }}
needs: [initialize]
env:
destination: frontend/coverage/lcov-report
strategy:
matrix:
value: ${{ fromJSON(needs.initialize.outputs.pull_requests)}}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.value.headRefName }}
fetch-depth: 1
token: ${{ github.token }}
- name: create directories
run: |
mkdir -p ${{ env.destination }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- run: npm ci
working-directory: ./frontend
- run: npm run coverage
continue-on-error: true
working-directory: ./frontend
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: prs-${{ matrix.value.number }}-coverage
path: ${{ env.destination }}
overwrite: true
f-build-stryker-for-each-pr:
timeout-minutes: 60
name: f - Stryker (${{ matrix.value.number }}, ${{ matrix.value.headRefName }})
runs-on: ubuntu-latest
if: ${{ needs.initialize.outputs.pull_requests != '[]' && needs.initialize.outputs.pull_requests != '' }}
needs: [initialize]
env:
destination: frontend/reports/mutation
history_destination: frontend/history
strategy:
matrix:
value: ${{ fromJSON(needs.initialize.outputs.pull_requests)}}
steps:
- uses: szenius/set-timezone@v2.0
with:
timezoneLinux: "America/Los_Angeles"
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ matrix.value.headRefName }}
fetch-depth: 2
token: ${{ github.token }}
- name: create directories
run: |
mkdir -p ${{ env.destination }}
mkdir -p ${{ env.history_destination}}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'frontend/package.json'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- run: npm ci
working-directory: ./frontend
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2.27.0
with:
workflow: 02-gh-pages-rebuild-part-1.yml
github_token: ${{secrets.GITHUB_TOKEN}}
branch: main
name: stryker-incremental-${{ matrix.value.number }}.json
path: ${{ env.history_destination }}
check_artifacts: true
if_no_artifact_found: warn
- name: Stryker (main, incremental)
working-directory: ./frontend
continue-on-error: true
run: |
npx stryker run --incremental --incrementalFile history/stryker-incremental-${{ matrix.value.number }}.json
- name: Upload stryker incremental file to Artifacts
uses: actions/upload-artifact@v4
with:
name: stryker-incremental-${{ matrix.value.number }}.json
path: ${{ env.history_destination }}
overwrite: true
- name: Upload to artifacts
uses: actions/upload-artifact@v4
with:
name: prs-${{ matrix.value.number }}-stryker
path: ${{ env.destination }}/mutation.html
overwrite: true