updates to tests; #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: CI - Main | |
on: | |
push: | |
branches: [main] | |
paths: | |
- src/** | |
- tests/** | |
- Dockerfile | |
- pylintrc | |
- pytest.ini | |
- requirements-test.txt | |
- requirements.txt | |
- run-ci.sh | |
workflow_dispatch: | |
jobs: | |
cache-requirements-install: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
id: cache-dependencies | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
run: | | |
pip install -r requirements-test.txt | |
test: | |
needs: cache-requirements-install | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Restore pip cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
pip install -r requirements-test.txt | |
- name: Test with pytest | |
run: | | |
pytest | |
- name: Upload coverage artifacts | |
uses: actions/upload-artifact@v3 | |
if: ${{ success() }} | |
with: | |
name: coverage-output | |
path: htmlcov | |
retention-days: 1 | |
- name: Checkout gh-pages | |
uses: actions/checkout@v3 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Generate Allure Report | |
uses: simple-elf/allure-report-action@master | |
if: always() | |
with: | |
allure_results: allure-results | |
subfolder: test-results | |
allure_report: allure-report | |
allure_history: allure-history | |
keep_reports: 100 | |
- name: Zip tests artifacts | |
run: zip test-output.zip allure-history/* -r | |
- name: Generate badges | |
run: | | |
python generate_badges.py | |
- name: Upload tests artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-output.zip | |
path: test-output.zip | |
retention-days: 1 | |
- name: Upload coverage artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-output | |
path: htmlcov | |
retention-days: 1 | |
- name: Upload badges artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: badges-output | |
path: badges | |
retention-days: 1 | |
publish-test-report: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download test artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: test-output.zip | |
# - name: Setup tmate session | |
# uses: mxschmitt/action-tmate@v3 | |
- name: Checkout gh-pages | |
uses: actions/checkout@v3 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: unzip tests artifacts | |
run: | | |
unzip test-output.zip && rm test-output.zip | |
- name: Publish test report to gh-pages | |
if: always() | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }} | |
publish_branch: gh-pages | |
publish_dir: allure-history/test-results | |
destination_dir: test-results | |
publish-coverage-report: | |
needs: publish-test-report | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download coverage artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage-output | |
path: coverage | |
- name: Checkout gh-pages | |
uses: actions/checkout@v3 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Publish test coverage to gh-pages | |
if: always() | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }} | |
publish_branch: gh-pages | |
publish_dir: coverage | |
destination_dir: test-coverage | |
publish-badges: | |
needs: publish-coverage-report | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download badges artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: badges-output | |
path: badges | |
- name: Checkout gh-pages | |
uses: actions/checkout@v3 | |
if: always() | |
continue-on-error: true | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Publish badges to gh-pages | |
if: always() | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }} | |
publish_branch: gh-pages | |
publish_dir: badges | |
destination_dir: badges | |
deploy: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check Out Repo | |
uses: actions/checkout@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
build-args: | | |
NEW_INSTALLATION_ENDPOINT=${{ secrets.NEW_INSTALLATION_ENDPOINT }} | |
NEW_HEARTBEAT_ENDPOINT=${{ secrets.NEW_HEARTBEAT_ENDPOINT }} | |
APP_VERSION=main | |
push: true | |
# platforms: linux/arm64, linux/amd64, linux/arm/v7, linux/386 | |
platforms: linux/arm64, linux/amd64 | |
tags: mandarons/icloud-drive:main | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |