From 21df3ee116dae81230cfb44dba51d9a6e1a19a35 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 02:20:30 -0400 Subject: [PATCH 1/7] tests: migrate to github actions --- .circleci/config.yml | 29 ----------------- .github/workflows/ci.yml | 70 ++++++++++++++++++++++++++++++++++++++++ Makefile | 4 +-- 3 files changed, 72 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index d0ea38e..0e101e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,27 +9,6 @@ commands: default: "3.7.0" steps: - checkout - - run: pyenv global << parameters.python_version >> - - run: make setup - - run: sudo sysctl -w vm.max_map_count=262144 - - run: - command: | - make generate - if ! git diff --quiet README.md; then - echo "Please run `make generate`" - git status --short - git --no-pager diff README.md - exit 1 - fi - - run: make test - - store_artifacts: - path: build - destination: build - - store_artifacts: - path: tmp/test-results - destination: test-results - - store_test_results: - path: tmp/test-results executors: machine: @@ -45,16 +24,8 @@ jobs: steps: - build - build-version: - environment: - DOKKU_VERSION: v0.19.0 - executor: machine - steps: - - build - workflows: version: 2 build: jobs: - "build-master" - - "build-version" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fd8dc46 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +--- +name: CI + +# yamllint disable-line rule:truthy +on: + pull_request: + branches: + - '*' + push: + branches: + - '*' + +jobs: + unit-tests: + name: unit-tests + runs-on: ubuntu-18.04 + strategy: + fail-fast: true + matrix: + dokku-version: + - master + env: + DOKKU_VERSION: ${{ matrix.dokku-version }} + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7.x' + + - run: make setup + + - run: sudo sysctl -w vm.max_map_count=262144 + + - run: | + make generate + if ! git diff --quiet README.md; then + echo "Please run `make generate`" + git status --short + git --no-pager diff README.md + exit 1 + fi + + - run: make test + + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: tmp/test-results + path: test-results + + publish-test-results: + name: publish-test-results + needs: unit-tests + runs-on: ubuntu-16.04 + if: success() || failure() + + steps: + - name: download test-results + uses: actions/download-artifact@v2 + with: + path: test-results + + - name: Publish Unit Test Results + uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.12 + with: + check_name: Unit Test Results + github_token: ${{ secrets.GITHUB_TOKEN }} + files: test-results/**/*.xml + comment_on_pr: false diff --git a/Makefile b/Makefile index e908c94..985f70c 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ ifneq ($(shell bats --version >/dev/null 2>&1 ; echo $$?),0) brew install bats-core endif else - git clone https://github.com/josegonzalez/bats-core.git /tmp/bats + git clone https://github.com/bats-core/bats-core.git /tmp/bats cd /tmp/bats && sudo ./install.sh /usr/local rm -rf /tmp/bats endif @@ -63,7 +63,7 @@ unit-tests: @echo running unit tests... @mkdir -p tmp/test-results/bats @cd tests && echo "executing tests: $(shell cd tests ; ls *.bats | xargs)" - cd tests && bats --formatter bats-format-junit -e -T -o ../tmp/test-results/bats *.bats + cd tests && bats --report-formatter junit --timing -o ../tmp/test-results/bats *.bats tmp/xunit-reader: mkdir -p tmp From dafc9c7a2d2e2545c096980140d4a2156236571f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 13:57:19 -0400 Subject: [PATCH 2/7] chore: update min dokku version and only test push on master branch --- .github/workflows/ci.yml | 3 ++- README.md | 6 +++--- bin/generate | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd8dc46..c36731a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: - '*' push: branches: - - '*' + - master jobs: unit-tests: @@ -19,6 +19,7 @@ jobs: matrix: dokku-version: - master + - v0.19.0 env: DOKKU_VERSION: ${{ matrix.dokku-version }} diff --git a/README.md b/README.md index b6b2675..ca11279 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ Official redis plugin for dokku. Currently defaults to installing [redis 5.0.7]( ## Requirements -- dokku 0.12.x+ +- dokku 0.19.x+ - docker 1.8.x ## Installation ```shell -# on 0.12.x+ +# on 0.19.x+ sudo dokku plugin:install https://github.com/dokku/dokku-redis.git redis ``` @@ -653,4 +653,4 @@ dokku redis:backup-unschedule lolipop If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `REDIS_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. -Please ensure the proper images are in place when `docker pull` is disabled. \ No newline at end of file +Please ensure the proper images are in place when `docker pull` is disabled. diff --git a/bin/generate b/bin/generate index 0ae59a5..47b488f 100755 --- a/bin/generate +++ b/bin/generate @@ -506,7 +506,7 @@ def main(): sponsors = re.search("\[([\"\w\s,_-]+)\]", line).group(1) sponsors = [s.strip("\"") for s in sponsors.split(",")] - text = compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, "0.12.x+") + text = compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, "0.19.x+") base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) readme_file = os.path.join(base_path, "README.md") From 14ec6fd8339eb50999ca8b40e82e33136892cd45 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:03:02 -0400 Subject: [PATCH 3/7] tests: split tests to version and tag --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c36731a..fcfee06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,17 +11,48 @@ on: - master jobs: - unit-tests: + unit-tests-master: name: unit-tests runs-on: ubuntu-18.04 strategy: fail-fast: true - matrix: - dokku-version: - - master - - v0.19.0 env: - DOKKU_VERSION: ${{ matrix.dokku-version }} + DOKKU_VERSION: master + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7.x' + + - run: make setup + + - run: sudo sysctl -w vm.max_map_count=262144 + + - run: | + make generate + if ! git diff --quiet README.md; then + echo "Please run `make generate`" + git status --short + git --no-pager diff README.md + exit 1 + fi + + - run: make test + + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: tmp/test-results + path: test-results + + unit-tests-0.19.0: + name: unit-tests-0.19.0 + runs-on: ubuntu-18.04 + strategy: + fail-fast: true + env: + DOKKU_TAG: v0.19.0 steps: - uses: actions/checkout@v2 From 8fda23f91c4a7b9c1dddce5d4af3a01b80418470 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:04:39 -0400 Subject: [PATCH 4/7] tests: fix job name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcfee06..319596c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: name: tmp/test-results path: test-results - unit-tests-0.19.0: + unit-tests-0_19_0: name: unit-tests-0.19.0 runs-on: ubuntu-18.04 strategy: From f48f67f67b952d72e1c89135662aa033679280c2 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:05:47 -0400 Subject: [PATCH 5/7] tests: drop copying of test results Bats will now output the results on stdout so no need to copy results anywhere. --- .github/workflows/ci.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 319596c..9b85b4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,23 +80,3 @@ jobs: with: name: tmp/test-results path: test-results - - publish-test-results: - name: publish-test-results - needs: unit-tests - runs-on: ubuntu-16.04 - if: success() || failure() - - steps: - - name: download test-results - uses: actions/download-artifact@v2 - with: - path: test-results - - - name: Publish Unit Test Results - uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.12 - with: - check_name: Unit Test Results - github_token: ${{ secrets.GITHUB_TOKEN }} - files: test-results/**/*.xml - comment_on_pr: false From fea5aa67242ff1148cbe5918ae2c450956fd1b68 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Apr 2021 14:09:33 -0400 Subject: [PATCH 6/7] docs: regenerate readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca11279..3eb7557 100644 --- a/README.md +++ b/README.md @@ -653,4 +653,4 @@ dokku redis:backup-unschedule lolipop If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `REDIS_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output. -Please ensure the proper images are in place when `docker pull` is disabled. +Please ensure the proper images are in place when `docker pull` is disabled. \ No newline at end of file From 04541a0fc6c320ee99025e143bedc79a24351c31 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 25 Apr 2021 00:35:43 -0400 Subject: [PATCH 7/7] tests: skip tests that require tty for github actions --- tests/service_export.bats | 3 +++ tests/service_import.bats | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/service_export.bats b/tests/service_export.bats index e381525..4d70d6e 100755 --- a/tests/service_export.bats +++ b/tests/service_export.bats @@ -20,6 +20,9 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:export) success with SSH_TTY" { + if [[ -n "$GITHUB_WORKFLOW" ]]; then + skip "No tty is available on Github Actions" + fi export SSH_TTY=`tty` run dokku "$PLUGIN_COMMAND_PREFIX:export" l echo "output: $output" diff --git a/tests/service_import.bats b/tests/service_import.bats index bbafcd2..3623008 100755 --- a/tests/service_import.bats +++ b/tests/service_import.bats @@ -24,6 +24,9 @@ teardown() { } @test "($PLUGIN_COMMAND_PREFIX:import) error when data is not provided" { + if [[ -n "$GITHUB_WORKFLOW" ]]; then + skip "No tty is available on Github Actions" + fi run dokku "$PLUGIN_COMMAND_PREFIX:import" l assert_contains "${lines[*]}" "No data provided on stdin" assert_failure