Skip to content

ci: run a full check in CI without building the docs (other phases do… #5260

ci: run a full check in CI without building the docs (other phases do…

ci: run a full check in CI without building the docs (other phases do… #5260

name: CI/CD Process
on:
workflow_call:
workflow_dispatch:
jobs:
# Runs all tests
build:
strategy:
matrix:
os: [ windows-2022, macos-12, ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
timeout-minutes: 180
concurrency:
group: ${{ github.workflow }}-build-${{ matrix.os }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: danysk/action-checkout@0.2.9
- uses: DanySK/build-check-deploy-gradle-action@2.2.4
with:
pre-build-command: ./gradlew kotlinUpgradeYarnLock --parallel
# check that all tasks used in subsequent phases are there
build-command: |
COMMAND="./gradlew \
build clean close \
hugoBuild \
performWebsiteStringReplacements \
publishKotlinOSSRHPublicationToGithubRepository \
release \
shadowJar \
uploadKotlinOSSRH uploadKotlinMultiplatform uploadJvm uploadJs \
--dry-run
"
eval $COMMAND || eval $COMMAND
check-command: |
./gradlew check --parallel || ./gradlew check --parallel
clean-command: |
./gradlew clean --parallel || ./gradlew clean --parallel || true
should-run-codecov: ${{ contains('Linux', runner.os) }}
should-deploy: false
should-validate-wrapper: ${{ contains('Linux', runner.os) }}
# Performs a dry-deployment if credentials are available
test-deploy:
runs-on: ubuntu-22.04
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
timeout-minutes: 120
concurrency:
group: ${{ github.workflow }}-test-deploy-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: danysk/action-checkout@0.2.9
- uses: DanySK/build-check-deploy-gradle-action@2.2.4
with:
build-command: ./gradlew kotlinUpgradeYarnLock --parallel
check-command: true
deploy-command: |
COMMAND="./gradlew uploadJvm uploadJs uploadKotlinOSSRH uploadKotlinMultiplatform close drop --parallel"
eval "$COMMAND" || eval "$COMMAND" || eval "$COMMAND"
java-version: 11
should-run-codecov: false
should-deploy: true
should-validate-wrapper: false
maven-central-password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
signing-key: ${{ secrets.SIGNING_KEY }}
signing-password: ${{ secrets.SIGNING_PASSWORD }}
# Builds the website and verifies link sanity
build-website:
runs-on: ubuntu-22.04
timeout-minutes: 30
concurrency:
group: ${{ github.workflow }}-build-website-${{ github.event.number || github.ref }}
cancel-in-progress: true
steps:
- name: Checkout
uses: danysk/action-checkout@0.2.9
- uses: DanySK/build-check-deploy-gradle-action@2.2.4
with:
build-command: |
for i in 1 2 3 4 5; do
./gradlew hugoBuild --parallel && break || sleep 120
if [ "$i" = 5 ]; then
false
fi
done
check-command: |
# Temporarily disable checks on kdoc/javadoc: too many bugs in Dokka.
# See:
# https://github.com/Kotlin/dokka/issues/2320
# https://github.com/Kotlin/dokka/issues/2321
# https://github.com/Kotlin/dokka/issues/2322
# https://github.com/Kotlin/dokka/issues/2323
# Once everything gets fixed, lychee could simply run on '/website/**/*.html'
FILES="$(find build/website/ -name '*.html' | grep -v /kdoc/ | grep -v /javadoc/ | sed -e 's#^build##')"
CHECK_LINKS="docker run --rm -v ""$(pwd)/build/website:/website"" -e GITHUB_TOKEN lycheeverse/lychee:0.10.3 $(echo "$FILES") --exclude-file /website/lycheeignore -m 100 --accept 403,429,500,502,503"
for i in 1 2 3 4 5; do
$(echo $CHECK_LINKS) && break || sleep 30
if [ "$i" = 5 ]; then
false
fi
done
should-run-codecov: false
should-deploy: false
should-validate-wrapper: false
- name: Tar files
run: tar -cvf website.tar build/website
- name: Upload website
uses: actions/upload-artifact@v3.1.2
with:
name: website
path: website.tar
# Performs a release if needed
release:
concurrency:
# Only one release job at a time per branch, as only master releases.
# Strictly sequential.
group: release-${{ github.event.number || github.ref }}
needs:
- build
- build-website
- test-deploy
runs-on: ubuntu-22.04
if: >-
!github.event.repository.fork
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
with:
submodules: recursive
token: ${{ secrets.DEPLOYMENT_TOKEN }}
- name: Checkout the docs
if: contains(github.repository, 'AlchemistSimulator/Alchemist')
uses: actions/checkout@v3.5.2
with:
path: website
fetch-depth: 0
persist-credentials: true
repository: AlchemistSimulator/alchemistsimulator.github.io
token: ${{ secrets.DEPLOYMENT_TOKEN }}
- name: Download website artifact
uses: actions/download-artifact@v3.0.2
with:
name: website
- name: Find the version of Node from package.json
id: node-version
run: echo "version=$(jq -r .engines.node package.json)" >> $GITHUB_OUTPUT
- name: Install Node
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ steps.node-version.outputs.version }}
- uses: DanySK/build-check-deploy-gradle-action@2.2.4
with:
java-version: 11
build-command: |
ls -ahl
echo Copying the new website
tar -xf website.tar
echo Copying git information
mv website/.git build/website/.git
# git -C build/website/ status
echo Removing old website
rm -rf website
echo Adding changes to the stage
git -C build/website/ add .
# git -C build/website/ status
check-command: true
deploy-command: |
npm install
npx semantic-release
should-run-codecov: false
should-deploy: true
should-validate-wrapper: false
github-token: ${{ secrets.DEPLOYMENT_TOKEN }}
maven-central-password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
signing-key: ${{ secrets.SIGNING_KEY }}
signing-password: ${{ secrets.SIGNING_PASSWORD }}
success:
runs-on: ubuntu-22.04
needs:
- build
- build-website
- release
- test-deploy
if: >-
always() && (
contains(join(needs.*.result, ','), 'failure')
|| !contains(join(needs.*.result, ','), 'cancelled')
)
steps:
- name: Verify that there were no failures
run: ${{ !contains(join(needs.*.result, ','), 'failure') }}