From afb8e89bd4c8707b29d554274c128a78b40f4f4e Mon Sep 17 00:00:00 2001 From: Sven Vogel Date: Thu, 4 Jul 2024 16:16:28 +0200 Subject: [PATCH] added: release on tag CI and changed CI script --- .gitea/workflows/release.yml | 26 ++++++++++++++++++ run-ci.sh | 51 +++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..9714e7b --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,26 @@ +name: release + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create release + id: create-release + uses: https://gitea.com/actions/release-action@main + with: + files: |- + src/** + template/** + LICENSE + typst.toml + README.md + example.pdf + api_key: '${{secrets.RELEASE_TOKEN}}' diff --git a/run-ci.sh b/run-ci.sh index 47cb00e..33cbe95 100755 --- a/run-ci.sh +++ b/run-ci.sh @@ -1,33 +1,42 @@ #!/bin/bash +function log() { + local timestamp=$(date +"%Y-%m-%d %H:%M:%S") + echo "$1 at $timestamp: $2" +} + function abort() { - echo "test case `$1` has failed" 1>&2 + log "ERROR" "test case $1 has failed" exit 1 } -echo "Compiling template..." -typst compile template/main.typ --root . || abort "template" +function print-box() { + printf "\\n" + echo ".----------------------------------------------------------------." + printf "| %-62s |\\n" "$1" + echo "'----------------------------------------------------------------'" +} -echo "Running tests..." +function enter-section() { + print-box "$1" -echo "Running test local-import..." -typst compile tests/local-import/main.typ --root . || abort "local-import" + log "INFO" "running task in section $1: $2" + log "INFO" "section output following..." + printf "\\n" -echo "Running test invalid-config..." + eval "$2" + if [ $? -neq $3 ]; then + abort "command: $2 failed in section: $1" + fi -echo "Expected to fail..." -typst compile tests/invalid-config/test-case-1.typ --root . -if [ $? -eq 0 ]; then - abort "invalid-config case 1" -fi + printf "\\n" + log "INFO" "section $1 completed successfully" +} -typst compile tests/invalid-config/test-case-2.typ --root . || abort "invalid-config case 2" +enter-section "Compiling template..." "typst compile template/main.typ --root . example.pdf" 0 +enter-section "TEST: local template import" "typst compile tests/local-import/main.typ --root ." 0 +enter-section "TEST: invalid config case 1" "typst compile tests/invalid-config/test-case-1.typ --root ." 1 +enter-section "TEST: invalid config case 2" "compile tests/invalid-config/test-case-2.typ" 0 +enter-section "TEST: invalid config case 3" "typst compile tests/invalid-config/test-case-3.typ --root ." 1 -echo "Expected to fail..." -typst compile tests/invalid-config/test-case-3.typ --root . -if [ $? -eq 0 ]; then - abort "invalid-config case 3b" -fi - - -echo "Tests completed successfully" +log "INFO" "CI completed successfully"