From 0baf1d03e9ff568652e62ecb881de3f7aba2f759 Mon Sep 17 00:00:00 2001 From: Nils K Date: Thu, 25 Nov 2021 21:54:37 +0100 Subject: new github action test --- .github/workflows/demo_page.yml | 25 +++++++++++++++++++++++++ .github/workflows/main.yml | 25 ------------------------- .github/workflows/shellcheck.yml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/ubuntu_2004.yml | 27 +++++++++++++++++++++++++++ test.sh | 38 ++++++++++++++++++++++++++++++++++++++ tests.sh | 38 -------------------------------------- 6 files changed, 122 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/demo_page.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/shellcheck.yml create mode 100644 .github/workflows/ubuntu_2004.yml create mode 100644 test.sh delete mode 100755 tests.sh diff --git a/.github/workflows/demo_page.yml b/.github/workflows/demo_page.yml new file mode 100644 index 0000000..30cdc23 --- /dev/null +++ b/.github/workflows/demo_page.yml @@ -0,0 +1,25 @@ +name: "Update gallery.sh demo page" +on: + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Dependencies 🔧 + run: sudo apt-get install imagemagick jhead + - name: Checkout 🛎️ + uses: actions/checkout@v2 + - name: Build 🖼️ + run: | + ls -lah + mkdir -p build/ + cp images/demo/* build/ + cd build/ + ls -lah + bash ../gallery.sh -t "Demo Gallery" -d "thumbs" + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@4.0.0 + with: + branch: gh-pages # The branch the action should deploy to. + folder: build # The folder the action should deploy. \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 30cdc23..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "Update gallery.sh demo page" -on: - workflow_dispatch: - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Dependencies 🔧 - run: sudo apt-get install imagemagick jhead - - name: Checkout 🛎️ - uses: actions/checkout@v2 - - name: Build 🖼️ - run: | - ls -lah - mkdir -p build/ - cp images/demo/* build/ - cd build/ - ls -lah - bash ../gallery.sh -t "Demo Gallery" -d "thumbs" - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@4.0.0 - with: - branch: gh-pages # The branch the action should deploy to. - folder: build # The folder the action should deploy. \ No newline at end of file diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..eab33b6 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,32 @@ +name: "ShellCheck" + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "test" + shellcheck: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Install dependencies 🔧 + run: sudo apt-get install shellcheck + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout 🛎️ + uses: actions/checkout@v2 + + # Run ShellCheck + - name: ShellCheck 🔎 + run: shellcheck gallery.sh \ No newline at end of file diff --git a/.github/workflows/ubuntu_2004.yml b/.github/workflows/ubuntu_2004.yml new file mode 100644 index 0000000..14cc360 --- /dev/null +++ b/.github/workflows/ubuntu_2004.yml @@ -0,0 +1,27 @@ +name: "Ubuntu 20.04 LTS" + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + + workflow_dispatch: + +jobs: + ubuntu-2004: + name: Test Ubuntu 20.04 LTS + runs-on: ubuntu-20.04 + steps: + + - name: Dependencies 🔧 + run: sudo apt-get install imagemagick jhead + + - name: Checkout 🛎️ + uses: actions/checkout@v2 + + - name: Get assert.sh 🎁 + run: curl -f "https://raw.githubusercontent.com/lehmannro/assert.sh/v1.1/assert.sh" -o assert.sh + + - name: Test 🛠️ + run: bash test.sh \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..c33e947 --- /dev/null +++ b/test.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# gallery.sh Test Script +# +# https://github.com/lehmannro/assert.sh + +if [ ! -e assert.sh ]; then + echo "downloading unit test script" + curl -f "https://raw.githubusercontent.com/lehmannro/assert.sh/v1.1/assert.sh" -o assert.sh +fi + +# Copy demo files +cp images/demo/* ./ + +# shellcheck disable=SC1091 +source assert.sh + +# `echo test` is expected to write "test" on stdout +assert "echo test" "test" +# `seq 3` is expected to print "1", "2" and "3" on different lines +assert "seq 3" "1\\n2\\n3" +# exit code of `true` is expected to be 0 +assert_raises "true" +# exit code of `false` is expected to be 1 +assert_raises "false" 1 +# end of test suite +assert_end examples + +# $ bash gallery.sh -t Test +assert_raises "bash gallery.sh -t Test" + +assert "cat index.html | grep 'Test' | tr -d '\011\012\015'" 'Test' +assert "cat index.html | grep '__thumbs/Landscape_1.jpg.html' | tr -d '\011\012\015'" 'Thumbnail: Landscape_1.jpg' + +assert "cat __thumbs/Landscape_1.jpg.html | grep 'Landscape_1.jpg' | tr -d '\011\012\015'" 'Landscape_1.jpg' +assert "cat __thumbs/Landscape_1.jpg.html | grep 'Resolution' | tr -d '\040\011\012\015'" 'Resolution:600x450' + +assert_end gallery_sh diff --git a/tests.sh b/tests.sh deleted file mode 100755 index c33e947..0000000 --- a/tests.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -# gallery.sh Test Script -# -# https://github.com/lehmannro/assert.sh - -if [ ! -e assert.sh ]; then - echo "downloading unit test script" - curl -f "https://raw.githubusercontent.com/lehmannro/assert.sh/v1.1/assert.sh" -o assert.sh -fi - -# Copy demo files -cp images/demo/* ./ - -# shellcheck disable=SC1091 -source assert.sh - -# `echo test` is expected to write "test" on stdout -assert "echo test" "test" -# `seq 3` is expected to print "1", "2" and "3" on different lines -assert "seq 3" "1\\n2\\n3" -# exit code of `true` is expected to be 0 -assert_raises "true" -# exit code of `false` is expected to be 1 -assert_raises "false" 1 -# end of test suite -assert_end examples - -# $ bash gallery.sh -t Test -assert_raises "bash gallery.sh -t Test" - -assert "cat index.html | grep 'Test' | tr -d '\011\012\015'" 'Test' -assert "cat index.html | grep '__thumbs/Landscape_1.jpg.html' | tr -d '\011\012\015'" 'Thumbnail: Landscape_1.jpg' - -assert "cat __thumbs/Landscape_1.jpg.html | grep 'Landscape_1.jpg' | tr -d '\011\012\015'" 'Landscape_1.jpg' -assert "cat __thumbs/Landscape_1.jpg.html | grep 'Resolution' | tr -d '\040\011\012\015'" 'Resolution:600x450' - -assert_end gallery_sh -- cgit v1.2.3