Repository: brennerm/check-mk-web-api (language: python)

Issue:
replace Travis with Github Actions
Closes #38 


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/publish-api-docs.yml b/.github/workflows/publish-api-docs.yml
new file mode 100644
index 0000000..a86e30e
--- /dev/null
+++ b/.github/workflows/publish-api-docs.yml
@@ -0,0 +1,24 @@
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  publish:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - name: setup Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: '3.6'
+      - name: install doc requirements
+        run: pip install -r requirements-doc.txt
+      - name: build docs
+        working-directory: doc
+        run: pydocmd build
+      - name: publish docs
+        uses: JamesIves/github-pages-deploy-action@4.0.0
+        with:
+          branch: gh-pages
+          folder: doc/_build/site
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 8fddf07..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-language: python
-python:
-  - 3.6
-services:
-  - docker
-sudo: required
-install:
-  - pip install -r requirements-doc.txt
-script:
-  - python2 -m py_compile check_mk_web_api/*.py
-  - python3 -m py_compile check_mk_web_api/*.py
-  - docker run -d --rm -p 127.0.0.1:8080:5000 --name check-mk checkmk/check-mk-raw:1.5.0-latest
-  - sleep 60
-  - docker exec -u cmk check-mk bash -c "echo automation-secret > /omd/sites/cmk/var/check_mk/web/automation/automation.secret"
-  - CHECK_MK_URL=http://localhost:8080/cmk/check_mk CHECK_MK_USER=automation CHECK_MK_SECRET=automation-secret CHECK_MK_VERSION="1.5" python setup.py test
-  - docker stop check-mk
-  - docker run -d --rm -p 127.0.0.1:8080:5000 --name check-mk checkmk/check-mk-raw:1.6.0-latest
-  - sleep 60
-  - docker exec -u cmk check-mk bash -c "echo automation-secret > /omd/sites/cmk/var/check_mk/web/automation/automation.secret"
-  - CHECK_MK_URL=http://localhost:8080/cmk/check_mk CHECK_MK_USER=automation CHECK_MK_SECRET=automation-secret CHECK_MK_VERSION="1.6" python setup.py test
-  - docker stop check-mk
-  - cd doc
-  - pydocmd build
-  - cd ..
-deploy:
- provider: pages
- skip_cleanup: true
- github_token: $GITHUB_TOKEN
- local_dir: doc/_build/site
- on:
-   branch: master


Test patch:
diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml
new file mode 100644
index 0000000..28d8a4b
--- /dev/null
+++ b/.github/workflows/run-e2e-tests.yml
@@ -0,0 +1,60 @@
+on:
+  pull_request:
+    branches:
+      - master
+  push:
+    branches:
+      - master
+
+jobs:
+  compile_code:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        python_version:
+          - 2.7
+          - 3.6
+          - 3.7
+          - 3.8
+    steps:
+      - uses: actions/checkout@v2
+      - name: setup Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python_version }}
+      - name: compile code
+        run: python -m py_compile check_mk_web_api/*.py
+
+  run_e2e:
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        checkmk_version:
+          - 1.5
+          - 1.6
+    steps:
+      - uses: actions/checkout@v2
+      - name: setup Python
+        uses: actions/setup-python@v2
+        with:
+          python-version: '3.6'
+      - name: start and preconfigure checkmk
+        run: |
+          docker run -d --rm -p 127.0.0.1:8080:5000 --name check-mk checkmk/check-mk-raw:${{ matrix.checkmk_version }}.0-latest
+          set +e                                                                                                                                                                                                                   
+
+          max_retry=300                                                                                                                                                                                                          
+          counter=0                                                                                             
+          until docker exec -u cmk check-mk bash -c "echo automation-secret > /omd/sites/cmk/var/check_mk/web/automation/automation.secret" > /dev/null
+          do
+             sleep 1
+             [[ counter -eq $max_retry ]] && echo "failed to set password after $counter tries...giving up" && exit 1
+             echo "#$counter: failed to set password. trying again..."
+             ((counter++))
+          done
+          echo Successfully set automation user password
+          
+      - name: execute E2E tests
+        run: |
+          CHECK_MK_URL=http://localhost:8080/cmk/check_mk CHECK_MK_USER=automation CHECK_MK_SECRET=automation-secret CHECK_MK_VERSION="${{ matrix.checkmk_version }}" python setup.py test