name: Test on: push: pull_request: schedule: - cron: '2 1 * * 6' # M H d m w (Sat 1:02) jobs: check: if: github.event_name != 'pull_request' || github.repository_owner != 'tqdm' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - uses: actions/setup-python@v2 - name: set PYSHA run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV - uses: actions/cache@v1 with: path: ~/.cache/pre-commit key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }} - name: dependencies run: pip install -U pre-commit - uses: reviewdog/action-setup@v1 - if: github.event_name != 'schedule' name: comment run: | if [[ $EVENT == pull_request ]]; then REPORTER=github-pr-review else REPORTER=github-check fi pre-commit run -a todo | reviewdog -efm="%f:%l: %m" -name=TODO -tee -reporter=$REPORTER -filter-mode nofilter pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} EVENT: ${{ github.event_name }} - run: pre-commit run -a --show-diff-on-failure test: if: github.event_name != 'pull_request' || github.repository_owner != 'tqdm' name: py${{ matrix.python }}-${{ matrix.os }} strategy: matrix: os: [ubuntu] python: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] include: - os: macos python: 2.7 - os: macos python: 3.8 - os: windows python: 2.7 - os: windows python: 3.8 runs-on: ${{ matrix.os }}-latest timeout-minutes: 35 defaults: run: shell: bash steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - name: install run: | pip install -U tox tox-gh-actions mkdir -p "$HOME/bin" curl -sfL https://coverage.codacy.com/get.sh > "$HOME/bin/codacy" chmod +x "$HOME/bin/codacy" echo "$HOME/bin" >> $GITHUB_PATH - name: tox run: | TIMEOUT=10m if [[ "${{ matrix.python }}" = "2.7" ]]; then TIMEOUT=15m elif [[ "py${{ matrix.python }}-${{ matrix.os }}" = "py3.8-ubuntu" ]]; then export TOXENV="py38-tf,py38-tf-keras" # full fi if [[ "${{ matrix.os }}" != "ubuntu" ]]; then tox -e py${PYVER/./} # basic else timeout $TIMEOUT tox || timeout $TIMEOUT tox || timeout $TIMEOUT tox fi env: PYVER: ${{ matrix.python }} PLATFORM: ${{ matrix.os }} COVERALLS_FLAG_NAME: py${{ matrix.python }}-${{ matrix.os }} COVERALLS_PARALLEL: true COVERALLS_SERVICE_NAME: github # coveralls needs explicit token COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} finish: if: github.event_name != 'pull_request' || github.repository_owner != 'tqdm' name: pytest cov continue-on-error: ${{ github.event_name != 'push' }} needs: test runs-on: ubuntu-latest steps: - uses: actions/setup-python@v2 - name: Coveralls Finished run: | pip install -U coveralls coveralls --finish || : env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Codacy Finished run: | curl -sfL https://coverage.codacy.com/get.sh > codacy bash codacy final || : env: CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} deploy: needs: [check, test] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - uses: actions/setup-python@v2 - name: Install run: | sudo apt-get install -yqq pandoc pip install -r .meta/requirements-build.txt make build .dockerignore Dockerfile snapcraft.yaml - id: dist uses: casperdcl/deploy-pypi@v2 with: password: ${{ secrets.PYPI_TOKEN }} gpg_key: ${{ secrets.GPG_KEY }} upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} - id: collect_assets name: Collect assets run: | if [[ $GITHUB_REF == refs/tags/v* ]]; then echo ::set-output name=docker_tags::latest,${GITHUB_REF/refs\/tags\/v/} echo ::set-output name=snap_channel::stable,candidate,edge elif [[ $GITHUB_REF == refs/heads/master ]]; then echo ::set-output name=docker_tags::master echo ::set-output name=snap_channel::candidate,edge elif [[ $GITHUB_REF == refs/heads/devel ]]; then echo ::set-output name=docker_tags::devel echo ::set-output name=snap_channel::edge fi echo ::set-output name=tag::${GITHUB_REF#refs/tags/} git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} with: name: tqdm ${{ steps.collect_assets.outputs.tag }} stable body_path: _CHANGES.md draft: true files: | dist/${{ steps.dist.outputs.whl }} dist/${{ steps.dist.outputs.whl_asc }} - uses: snapcore/action-build@v1 id: snap_build - if: github.event_name == 'push' && steps.collect_assets.outputs.snap_channel uses: snapcore/action-publish@v1 with: store_login: ${{ secrets.SNAP_TOKEN }} snap: ${{ steps.snap_build.outputs.snap }} release: ${{ steps.collect_assets.outputs.snap_channel }} - name: Docker build push uses: elgohr/Publish-Docker-Github-Action@master with: name: ${{ github.repository }} tags: ${{ steps.collect_assets.outputs.docker_tags }} password: ${{ secrets.DOCKER_PWD }} username: ${{ secrets.DOCKER_USR }} no_push: ${{ steps.collect_assets.outputs.docker_tags == '' }} - name: Docker push GitHub uses: elgohr/Publish-Docker-Github-Action@master with: name: ${{ github.repository }}/tqdm tags: ${{ steps.collect_assets.outputs.docker_tags }} password: ${{ github.token }} username: ${{ github.actor }} registry: docker.pkg.github.com no_push: ${{ steps.collect_assets.outputs.docker_tags == '' }}