From fbc96f20819a432dac9a97d4471ccac0386fe742 Mon Sep 17 00:00:00 2001 From: kra3 <48812+kra3@users.noreply.github.com> Date: Sun, 9 May 2021 21:50:39 +0200 Subject: [PATCH] unify actions --- .github/workflows/ci-cd.yml | 133 ++++++++++++++++++++++++++ .github/workflows/codeql-analysis.yml | 51 ---------- .github/workflows/python-package.yml | 62 ------------ .github/workflows/python-publish.yml | 30 ------ setup.py | 2 +- 5 files changed, 134 insertions(+), 144 deletions(-) create mode 100644 .github/workflows/ci-cd.yml delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/python-package.yml delete mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..a597eb5 --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,133 @@ +name: py-ga-mob + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [created] + schedule: + - cron: '1 3 * * 1' + +jobs: + analyze: + name: Analyze + if: github.event_name != 'release' + runs-on: ubuntu-latest + + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'python' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 + + build: + name: CI + if: ${{ github.event_name != 'release' || github.event_name != 'schedule' }} + runs-on: ubuntu-latest + strategy: + matrix: + language: [ 'python' ] + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache pip artifacts + uses: actions/cache@v2 + with: + # This path is specific to Ubuntu + path: ~/.cache/pip + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + ${{ runner.os }}- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python setup.py install + + #- name: Audit + # run: | + # pylama pyga -i E501 + + - name: Test ${{ matrix.test_number }} + run: | + python setup.py test + # coverage run --source=pyga setup.py test + + #- name: Coveralls Parallel + # uses: coverallsapp/github-action@master + # with: + # github-token: ${{ secrets.github_token }} + # flag-name: run-${{ matrix.test_number }} + # parallel: true + + #finish: + # needs: build + # runs-on: ubuntu-latest + # steps: + # - name: Coveralls Finished + # uses: coverallsapp/github-action@master + # with: + # github-token: ${{ secrets.github_token }} + # parallel-finished: true + + deploy: + name: CD + if: ${{ github.event_name == 'release' && github.event.release.action == 'released' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index a1df39d..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - schedule: - - cron: '1 3 * * 1' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - python-version: [3.6, 3.7, 3.8, 3.9] - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # setup-python-dependencies: false - # - run: | - # python -m pip install --upgrade pip - # if [ -f requirements.txt ]; - # then pip install -r requirements.txt; - # fi - # echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml deleted file mode 100644 index 6f9ea70..0000000 --- a/.github/workflows/python-package.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Build & Test - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.6, 3.7, 3.8, 3.9] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Cache pip - uses: actions/cache@v2 - with: - # This path is specific to Ubuntu - path: ~/.cache/pip - # Look to see if there is a cache hit for the corresponding requirements file - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pylama coveralls - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - python setup.py install - #- name: Audit - # run: | - # pylama pyga -i E501 - - name: Test ${{ matrix.test_number }} - run: | - python setup.py test - # coverage run --source=pyga setup.py test - #- name: Coveralls Parallel - # uses: coverallsapp/github-action@master - # with: - # github-token: ${{ secrets.github_token }} - # flag-name: run-${{ matrix.test_number }} - # parallel: true - - #finish: - # needs: build - # runs-on: ubuntu-latest - # steps: - # - name: Coveralls Finished - # uses: coverallsapp/github-action@master - # with: - # github-token: ${{ secrets.github_token }} - # parallel-finished: true - diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index dd2e485..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,30 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -name: Upload Python Package - -on: - release: - types: [created] - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* diff --git a/setup.py b/setup.py index 91e1529..2eb2160 100755 --- a/setup.py +++ b/setup.py @@ -36,5 +36,5 @@ 'Topic :: Internet :: WWW/HTTP :: WSGI', ], test_suite='tests', - tests_require=['mock',] + tests_require=['mock', 'python-coveralls'] )