Skip to content

containerize fosdem-dl #19

containerize fosdem-dl

containerize fosdem-dl #19

Workflow file for this run

name: 'CI/CD'
on:
pull_request:
push:
branches:
- canary
- main
env:
APP_ID: fosdem-dl
GRAALVM_VERSION: 23.0.0
HEAP_SIZE_AT_BUILD_TIME: '-R:MaxHeapSize=1024m'
JAVA_VERSION: 21
OPTIMIZATION_LEVEL: '-O2'
POD_JACKDBD_JSOUP_VERSION: 0.4.0-RC.1
jobs:
shared-outputs:
name: Shared outputs
runs-on: ubuntu-latest
env:
# Note: we can't run Babashka commands until we have downloaded the pod
# and moved it to the location specified in bb.edn.
# APP_VERSION=$(bb -e '(-> (slurp "deps.edn") edn/read-string :aliases :neil :project :version)' | tr -d '"')
APP_VERSION: 0.1.0-RC.1
outputs:
app_version: ${{ steps.set_outputs.outputs.app_version }}
is_prerelease: ${{ steps.set_outputs.outputs.is_prerelease }}
steps:
- name: Set job outputs
id: set_outputs
run: |
echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "is_prerelease=false" >> $GITHUB_OUTPUT
else
echo "is_prerelease=true" >> $GITHUB_OUTPUT
fi
- name: Log job outputs
run: |
echo "app_version is ${{ steps.set_outputs.outputs.app_version }}"
echo "is_prerelease is ${{ steps.set_outputs.outputs.is_prerelease }}"
uberjar:
name: Uberjar
needs: [shared-outputs]
runs-on: ubuntu-latest
env:
APP_VERSION: ${{ needs.shared-outputs.outputs.app_version }}
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🔧 Setup Clojure CLI and Babashka
uses: DeLaGuardo/[email protected]
with:
cli: 'latest'
bb: 'latest'
# This action uses the GitHub CLI.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows
- name: ⬇️ Download com.github.jackdbd/pod-jackdbd-jsoup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download_pod_jackdbd_jsoup.sh
- name: ⬆️ Upload pod-jackdbd-jsoup
uses: actions/upload-artifact@v4
with:
name: pod-jackdbd-jsoup
path: resources/pod/pod-jackdbd-jsoup
if-no-files-found: error
- name: 📦 Build a Babashka uberjar
run: bb build:bb-uber
- name: "CLI talks --help"
run: bb target/${{env.APP_ID }}-${{ env.APP_VERSION }}.jar talks --help
- name: "CLI tracks --help"
run: bb target/${{env.APP_ID }}-${{ env.APP_VERSION }}.jar tracks --help
- name: ⬆️ Upload Babashka uberjar
uses: actions/upload-artifact@v4
with:
name: bb-uberjar
path: target/${{ env.APP_ID }}-${{ env.APP_VERSION }}.jar
if-no-files-found: error
- name: 📦 Build normal uberjar
run: |
clojure -T:build clean
clojure -T:build uber
- name: ⬆️ Upload uberjar
uses: actions/upload-artifact@v4
with:
name: uberjar
path: target/${{ env.APP_ID }}-${{ env.APP_VERSION }}-standalone.jar
if-no-files-found: error
container-image:
name: Container image
needs: [shared-outputs, uberjar]
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🔧 Setup Clojure CLI and Babashka
uses: DeLaGuardo/[email protected]
with:
cli: 'latest'
bb: 'latest'
# - name: ⬇️ Download Babashka uberjar
# uses: actions/download-artifact@v4
# with:
# name: bb-uberjar
- name: 🐋 Build container image
run: bb container:build
- name: 🐋 Run container
run: |
bb container:cli help
bb container:cli talks --help
bb container:cli tracks --help
linux-binary:
name: Linux binary
needs: [shared-outputs, uberjar, create-github-release]
runs-on: ubuntu-latest
env:
APP_VERSION: ${{ needs.shared-outputs.outputs.app_version }}
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🔧 Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
check-for-updates: true
distribution: graalvm-community
java-version: ${{ env.JAVA_VERSION }}
native-image-job-reports: true
native-image-pr-reports: true
version: ${{ env.GRAALVM_VERSION }}
- name: 🔧 Setup Clojure CLI and Babashka
uses: DeLaGuardo/[email protected]
with:
cli: 'latest'
bb: 'latest'
# This action uses the GitHub CLI.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/using-github-cli-in-workflows
- name: ⬇️ Download com.github.jackdbd/pod-jackdbd-jsoup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download_pod_jackdbd_jsoup.sh
- name: 🔍 Run all tests
run: bb test_runner.clj
# https://github.com/liquidz/babashka-test-action/
# - name: Run babashka-test-action
# uses: liquidz/babashka-test-action@v1
# with:
# source-paths: 'src'
# test-paths: 'test'
# test-file-pattern: '_test.clj$'
- name: ⬇️ Download uberjar
uses: actions/download-artifact@v4
with:
name: uberjar
- name: Copy the uberjar and the binary to the target directory
run: |
mkdir target
cp ${{ env.APP_ID }}-${{ env.APP_VERSION }}-standalone.jar target/
- name: 📦 Compile uberjar to x86_64-linux binary with GraalVM native-image
run: ./script/compile.sh
macos-binary:
name: macOS binary
needs: [shared-outputs, uberjar, create-github-release]
runs-on: macos-latest
env:
APP_VERSION: ${{ needs.shared-outputs.outputs.app_version }}
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🔧 Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
check-for-updates: true
distribution: graalvm-community
java-version: ${{ env.JAVA_VERSION }}
native-image-job-reports: true
native-image-pr-reports: true
version: ${{ env.GRAALVM_VERSION }}
- name: ⬇️ Download uberjar
uses: actions/download-artifact@v4
with:
name: uberjar
- name: Copy the uberjar and the binary to the target directory
run: |
mkdir target
cp ${{ env.APP_ID }}-${{ env.APP_VERSION }}-standalone.jar target/
- name: 📦 Compile uberjar to AArch64-macOS binary with GraalVM native-image
run: |
native-image \
-jar ${{ env.APP_ID }}-${{ env.APP_VERSION }}-standalone.jar \
'-H:ReflectionConfigurationFiles=reflection.json' \
'-H:+ReportExceptionStackTraces' \
'-J-Dclojure.compiler.direct-linking=true' \
${{ env.HEAP_SIZE_AT_BUILD_TIME }} \
${{ env.OPTIMIZATION_LEVEL }} \
'-march=armv8-a' \
'--initialize-at-build-time' \
'--native-image-info' \
'--no-fallback' \
'--report-unsupported-elements-at-runtime'
create-github-release:
name: Create GitHub release
if: ${{ github.event_name != 'pull_request' }}
needs: [shared-outputs, uberjar]
runs-on: ubuntu-latest
env:
APP_VERSION: ${{ needs.shared-outputs.outputs.app_version }}
IS_PRERELEASE: ${{ needs.shared-outputs.outputs.is_prerelease }}
permissions:
contents: write
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: ⬇️ Download uberjar
uses: actions/download-artifact@v4
with:
name: uberjar
- name: ⬇️ Download bb-uberjar
uses: actions/download-artifact@v4
with:
name: bb-uberjar
# Troubleshooting: do we have every assets we want to include in the GitHub release?
- run: ls -R
# https://github.com/marketplace/actions/gh-release
- name: Add uberjar to GitHub release
uses: softprops/action-gh-release@v2
id: github_release
with:
body: |
📦 **${{ env.APP_ID }}** version `${{ env.APP_VERSION }}`.
You will also need to download a [release of pod-jackdbd-jsoup](https://github.com/jackdbd/pod-jackdbd-jsoup/releases) and extact the pod to `resources/pod/pod-jackdbd-jsoup`.
# draft: true
fail_on_unmatched_files: true
files: |
${{ env.APP_ID }}-${{ env.APP_VERSION }}-standalone.jar
${{ env.APP_ID }}-${{ env.APP_VERSION }}.jar
# body is prepended to these automatically generated release notes.
# See here for how to configure these release notes:
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
generate_release_notes: true
name: v${{ env.APP_VERSION }}
prerelease: ${{ env.IS_PRERELEASE }}
tag_name: v${{ env.APP_VERSION }}
update-github-release:
name: Update GitHub release
if: ${{ github.event_name != 'pull_request' }}
needs: [create-github-release, linux-binary, macos-binary]
runs-on: ubuntu-latest
steps:
- name: TODO update GitHub release
run: echo "update GitHub release with all binaries compiled with GraalVM native-image"