-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
113 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,55 +5,130 @@ | |
# change your sbt build configuration to revise the workflow description | ||
# to meet your needs, then regenerate this file. | ||
|
||
name: Clean | ||
name: Continuous Integration | ||
|
||
on: push | ||
on: | ||
pull_request: | ||
branches: ['**'] | ||
push: | ||
branches: ['**'] | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
delete-artifacts: | ||
name: Delete Artifacts | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
build: | ||
name: Build and Test | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest] | ||
scala: [2.13.13, 3.3.1] | ||
java: [temurin@17] | ||
clickhouse: [21.3, 21.8.14, 22.3] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Delete artifacts | ||
run: | | ||
# Customize those three lines with your repository and credentials: | ||
REPO=${GITHUB_API_URL}/repos/${{ github.repository }} | ||
- name: Checkout current branch (full) | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Docker Compose Action | ||
uses: isbang/[email protected] | ||
env: | ||
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }} | ||
with: | ||
compose-file: './docker-compose.yml' | ||
down-flags: '--volumes' | ||
|
||
- name: Setup Java (temurin@17) | ||
if: matrix.java == 'temurin@17' | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
|
||
- name: Cache sbt | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.sbt | ||
~/.ivy2/cache | ||
~/.coursier/cache/v1 | ||
~/.cache/coursier/v1 | ||
~/AppData/Local/Coursier/Cache/v1 | ||
~/Library/Caches/Coursier/v1 | ||
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
# A shortcut to call GitHub API. | ||
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } | ||
# - name: Check that workflows are up to date | ||
# run: sbt ++${{ matrix.scala }} githubWorkflowCheck | ||
|
||
# A temporary file which receives HTTP response headers. | ||
TMPFILE=/tmp/tmp.$$ | ||
- name: Build project | ||
run: sbt ++${{ matrix.scala }} test it:test | ||
|
||
# An associative array, key: artifact name, value: number of artifacts of that name. | ||
declare -A ARTCOUNT | ||
- name: Compress target directories | ||
run: tar cf targets.tar target client/target dsl/target testkit/target project/target | ||
|
||
# Process all artifacts on this repository, loop on returned "pages". | ||
URL=$REPO/actions/artifacts | ||
while [[ -n "$URL" ]]; do | ||
- name: Upload target directories | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} | ||
path: targets.tar | ||
|
||
# Get current page, get response headers in a temporary file. | ||
JSON=$(ghapi --dump-header $TMPFILE "$URL") | ||
publish: | ||
name: Publish Artifacts | ||
needs: [build] | ||
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main') | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
scala: [2.13.13, 3.3.1] | ||
java: [temurin@17] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout current branch (full) | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Java (temurin@17) | ||
if: matrix.java == 'temurin@17' | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
# Get URL of next page. Will be empty if we are at the last page. | ||
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//') | ||
rm -f $TMPFILE | ||
- name: Cache sbt | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.sbt | ||
~/.ivy2/cache | ||
~/.coursier/cache/v1 | ||
~/.cache/coursier/v1 | ||
~/AppData/Local/Coursier/Cache/v1 | ||
~/Library/Caches/Coursier/v1 | ||
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} | ||
|
||
# Number of artifacts on this page: | ||
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) | ||
- name: Download target directories (3.3.1) | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: target-${{ matrix.os }}-3.3.1-${{ matrix.java }} | ||
|
||
# Loop on all artifacts on this page. | ||
for ((i=0; $i < $COUNT; i++)); do | ||
- name: Inflate target directories (3.3.1) | ||
run: | | ||
tar xf targets.tar | ||
rm targets.tar | ||
# Get name of artifact and count instances of this name. | ||
name=$(jq <<<$JSON -r ".artifacts[$i].name?") | ||
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) | ||
- name: Download target directories (2.13.13) | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: target-${{ matrix.os }}-2.13.13-${{ matrix.java }} | ||
|
||
- name: Inflate target directories (2.13.13) | ||
run: | | ||
tar xf targets.tar | ||
rm targets.tar | ||
id=$(jq <<<$JSON -r ".artifacts[$i].id?") | ||
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) | ||
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size | ||
ghapi -X DELETE $REPO/actions/artifacts/$id | ||
done | ||
done | ||
- name: Publish project | ||
run: sbt ++${{ matrix.scala }} +publish |