Repository: pallets-eco/flask-classful (language: python)

Issue:
should use github actions to run CI checks to replace travis-ci
as travis-ci is not available anymore.


Discussion / hints:
related: #137 
reopened to work on the docs publishing

Fix patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d4674fd..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,61 +0,0 @@
-sudo: false
-language: python
-dist: xenial
-env:
-  global:
-  - MOST_TESTED_PYTHON_VERSION=3.8
-  - COVERAGE_PYTHON_VERSION=2.7
-  - FLASK_LATEST=1.1.1
-  matrix:
-  # - Flask=0.11
-  # - Flask=0.11.1
-  # - Flask=0.12
-  # - Flask=0.12.1
-  # - Flask=0.12.2
-#  - Flask=0.12.3 # buggy, not supported, see related: https://github.com/dpgaspar/Flask-AppBuilder/issues/741
-  # - Flask=0.12.4
-  - Flask=1.0
-  - Flask=1.0.1
-  - Flask=1.0.2
-  - Flask=1.0.3
-  - Flask=1.0.4
-  - Flask=1.1.0
-  - Flask=1.1.1
-python:
-- 2.7
-#- 3.4
-- 3.5
-- 3.6
-- 3.7
-- 3.8
-before_script:
-- git config --global user.name "Teracy Bot"
-- git config --global user.email "teracy.com@gmail.com"
-- if [[ -z ${GH_REPO+x} ]]; then
-  export GH_REPO=teracyhq/flask-classful; fi
-- export REPO_URL_GITHUB="https://$GH_TOKEN@github.com/$GH_REPO.git"
-- . ./.travis/setup.sh
-- echo $DEPLOY_HTML_DIR
-install:
-- make resolve
-- pip install Flask==$Flask
-# test with webargs
-# see: https://github.com/marshmallow-code/webargs/issues/355
-- pip install webargs!=5.0.0
-- python setup.py install
-script:
-- make test
-after_script:
-- if [[ ! -z ${DEPLOY_HTML_DIR+x} && $TRAVIS_PYTHON_VERSION == $MOST_TESTED_PYTHON_VERSION && $Flask == $FLASK_LATEST ]]; then
-  pip install -r docs/requirements.txt && cd docs && make setup_gh_pages && make generate && make deploy; fi
-after_success:
-- if [[ $TRAVIS_PYTHON_VERSION == $COVERAGE_PYTHON_VERSION && $Flask == $FLASK_LATEST ]]; then pip install
-  --quiet python-coveralls && make report-coverage && coveralls; fi
-- make check-style
-notifications:
-  slack:
-    on_success: change
-    on_failure: always
-    on_pull_requests: false
-    rooms:
-      secure: CkrarcR2syf+Eu9TbVX7Hdnz++/OzV8TrPxX01Ok6lIz45ItjFby3HohdGiv/LdqAF91qP6cHzoADByoAAIDyExjsfJimMDtLfX6ZWAq8/WBS0g8bqpBv7s0ydPNB51DgzJNRh7adVExT3dhqO4XKcKmgL5UIOTLcouopB/cCn6/p6/B4l9I7AccHPRcPfsxgQnyUQPjpe2tyg/kpr0OHn+jdsiv0aTF9vmC1hSr/h3vTNDjp10jwW8XLaZIYUvATmwwXbADDB4DOAuVHtBV92bmDSwyZiBV7hqU9mqqVSdkDoHp/6nGBtJpsgaGEvPESCm2LdJrvfJNg+goYrmbaIr07kuISvbEjQxTX2MPsxTJy0Qmre9Ki6yXlJ/rSxAo2G6FMAUiqpKVV86L3g9Sway7Ovp5ihlZoJGMcA79y8WYAuSDN6PjY9GVksXiWr0cKFzBf/sBRTS4Zn60JLJSDA57KPny6DITN0WrMQFzc0hVVLINRjUhR4Nwn8P1TZVMGN+LRCOGj1/8MTgiZA9JaQbhjoWng+1M5f7BE9NKgOVVXn1+F2EI+ik+tiMpFfyinUPdgHS3SnVkd7Ja7dI1YG4MuJiCqS5WnEGXCu0xCOKbM2JyUtfnsw/IgsLnZ52G9+eI9W8Qq0GQ8S95Z4qsniZo49tU9g5bSKiN5rKiUSY=
diff --git a/.travis/setup.sh b/.travis/setup.sh
deleted file mode 100644
index 71fea78..0000000
--- a/.travis/setup.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-#setup travis-ci configuration basing one the being-built branch
-
-if [[ $TRAVIS_BRANCH == 'master' ]] ; then
-    export DEPLOY_HTML_DIR=.
-elif [[ $TRAVIS_BRANCH == 'develop' ]] ; then
-    export DEPLOY_HTML_DIR=develop
-elif [[ $TRAVIS_BRANCH =~ ^v[0-9.]+$ ]]; then
-    export DEPLOY_HTML_DIR=${TRAVIS_BRANCH:1}
-elif [[ $TRAVIS_BRANCH =~ ^[0-9.]+\.x$ || $TRAVIS_BRANCH =~ ^releases\/[0-9.]+$ ]]; then
-    export DEPLOY_HTML_DIR=$TRAVIS_BRANCH
-fi
diff --git a/docker-compose.yml b/docker-compose.yml
index ede967d..9b85086 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,3 +12,23 @@ services:
       RUN_TEST: ${RUN_TEST:-yes}
     volumes:
       - .:/opt/app
+
+
+  docs-gen:
+    image: python:3.8
+    working_dir: /opt/app/docs
+    command: >
+      bash -c "pip install -r requirements.txt
+      && make generate"
+    volumes:
+      - .:/opt/app
+
+  release:
+    image: python:3.8
+    working_dir: /opt/app
+    command: sh run-release.sh
+    environment:
+      TWINE_USERNAME: ${TWINE_USERNAME}
+      TWINE_PASSWORD: ${TWINE_PASSWORD}
+    volumes:
+      - .:/opt/app
diff --git a/run-release.sh b/run-release.sh
new file mode 100755
index 0000000..5533675
--- /dev/null
+++ b/run-release.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# see: https://gist.github.com/robin-a-meade/58d60124b88b60816e8349d1e3938615
+set -eu pipefail
+
+pip install twine
+
+rm -rf dist
+
+python setup.py sdist bdist_wheel --universal
+
+twine upload dist/*
+


Test patch:
diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test-docs.yaml
similarity index 52%
rename from .github/workflows/lint-test.yaml
rename to .github/workflows/lint-test-docs.yaml
index 283223e..5ab9d83 100644
--- a/.github/workflows/lint-test.yaml
+++ b/.github/workflows/lint-test-docs.yaml
@@ -1,4 +1,4 @@
-name: Lint and Test
+name: Lint, Test & Docs
 
 on:
   push:
@@ -7,9 +7,9 @@ on:
   # curl -X POST https://api.github.com/repos/:owner/:repo/dispatches \
   # -H 'Accept: application/vnd.github.everest-preview+json' \
   # -H 'Authorization: token TOKEN_VALUE_HERE' \
-  # --data '{"event_type":"lint-test","client_payload":{}}'
+  # --data '{"event_type":"lint-test-docs","client_payload":{}}'
   repository_dispatch:
-    types: [lint-test]
+    types: [lint-test-docs]
 
 jobs:
 
@@ -66,3 +66,42 @@ jobs:
         CHECK_STYLE: no
         DEV_IMAGE: python:${{ matrix.python }}
         FLASK: ${{ matrix.flask }}
+
+  # build and publish docs
+  docs:
+    if: github.event_name != 'pull_request'
+    needs: [lint, test]
+    runs-on: ubuntu-20.04
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: gen docs
+      run: |
+        docker-compose run --rm docs-gen
+
+    # the target folder to be deployed on the gh_pages branch
+    - name: set target folder
+      id: set_target_folder
+      run: |
+        GIT_BRANCH=$(echo ${GITHUB_REF} | sed -e "s/refs\/heads\///g" | sed -e "s/refs\/tags\///g" \
+        | sed -e "s/refs\/pull\///g")
+        echo "\$GIT_BRANCH: $GIT_BRANCH"
+        if [[ $GIT_BRANCH == 'master' ]] || [[ $GIT_BRANCH == 'main' ]] ; then
+            TARGET_FOLDER=.
+        elif [[ $GIT_BRANCH == 'develop' ]] ; then
+            TARGET_FOLDER=develop
+        elif [[ $GIT_BRANCH =~ ^v[0-9.]+[0-9.a-z\-]*$ ]]; then
+            TARGET_FOLDER=${GIT_BRANCH:1}
+        elif [[ $GIT_BRANCH =~ ^[0-9.]+[0-9.a-z\-]*$ || $GIT_BRANCH =~ ^releases\/[0-9.]+[0-9.a-z\-]*$ ]]; then
+            TARGET_FOLDER=$GIT_BRANCH
+        fi
+        echo "\$TARGET_FOLDER: $TARGET_FOLDER"
+        echo "::set-output name=target_folder::$TARGET_FOLDER"
+
+    - name: publish docs
+      uses: JamesIves/github-pages-deploy-action@4.1.8
+      if: steps.set_target_folder.outputs.target_folder != ''
+      with:
+        branch: gh-pages
+        folder: docs/_build/html
+        target-folder: ${{ steps.set_target_folder.outputs.target_folder }}