|
| 1 | +name: ci/cd |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + release: |
| 9 | + types: [created] |
| 10 | + schedule: |
| 11 | + - cron: '1 3 * * 1' |
| 12 | + |
| 13 | +jobs: |
| 14 | + analyze: |
| 15 | + name: Analyze |
| 16 | + if: github.event_name != 'release' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + permissions: |
| 20 | + actions: read |
| 21 | + contents: read |
| 22 | + security-events: write |
| 23 | + |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + language: [ 'python' ] |
| 28 | + python-version: [3.6, 3.7, 3.8, 3.9] |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@v2 |
| 33 | + |
| 34 | + - name: Set up Python |
| 35 | + uses: actions/setup-python@v2 |
| 36 | + with: |
| 37 | + python-version: '3.x' |
| 38 | + |
| 39 | + # Initializes the CodeQL tools for scanning. |
| 40 | + - name: Initialize CodeQL |
| 41 | + uses: github/codeql-action/init@v1 |
| 42 | + with: |
| 43 | + languages: ${{ matrix.language }} |
| 44 | + |
| 45 | + - name: Perform CodeQL Analysis |
| 46 | + uses: github/codeql-action/analyze@v1 |
| 47 | + |
| 48 | + build: |
| 49 | + name: CI |
| 50 | + if: ${{ github.event_name != 'release' || github.event_name != 'schedule' }} |
| 51 | + runs-on: ubuntu-latest |
| 52 | + strategy: |
| 53 | + matrix: |
| 54 | + python-version: [3.6, 3.7, 3.8, 3.9] |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout repository |
| 58 | + uses: actions/checkout@v2 |
| 59 | + |
| 60 | + - name: Set up Python ${{ matrix.python-version }} |
| 61 | + uses: actions/setup-python@v2 |
| 62 | + with: |
| 63 | + python-version: ${{ matrix.python-version }} |
| 64 | + |
| 65 | + - name: Cache pip artifacts |
| 66 | + uses: actions/cache@v2 |
| 67 | + with: |
| 68 | + # This path is specific to Ubuntu |
| 69 | + path: ~/.cache/pip |
| 70 | + # Look to see if there is a cache hit for the corresponding requirements file |
| 71 | + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} |
| 72 | + restore-keys: | |
| 73 | + ${{ runner.os }}-pip- |
| 74 | + ${{ runner.os }}- |
| 75 | +
|
| 76 | + - name: Install dependencies |
| 77 | + run: | |
| 78 | + python -m pip install --upgrade pip |
| 79 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 80 | + python setup.py install |
| 81 | +
|
| 82 | + #- name: Audit |
| 83 | + # run: | |
| 84 | + # pylama pyga -i E501 |
| 85 | + |
| 86 | + - name: Test ${{ matrix.test_number }} |
| 87 | + run: | |
| 88 | + python setup.py test |
| 89 | + # coverage run --source=pyga setup.py test |
| 90 | +
|
| 91 | + #- name: Coveralls Parallel |
| 92 | + # uses: coverallsapp/github-action@master |
| 93 | + # with: |
| 94 | + # github-token: ${{ secrets.github_token }} |
| 95 | + # flag-name: run-${{ matrix.test_number }} |
| 96 | + # parallel: true |
| 97 | + |
| 98 | + #finish: |
| 99 | + # needs: build |
| 100 | + # runs-on: ubuntu-latest |
| 101 | + # steps: |
| 102 | + # - name: Coveralls Finished |
| 103 | + # uses: coverallsapp/github-action@master |
| 104 | + # with: |
| 105 | + # github-token: ${{ secrets.github_token }} |
| 106 | + # parallel-finished: true |
| 107 | + |
| 108 | + deploy: |
| 109 | + name: CD |
| 110 | + if: ${{ github.event_name == 'release' && github.event.release.action == 'released' }} |
| 111 | + runs-on: ubuntu-latest |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Checkout repository |
| 115 | + uses: actions/checkout@v2 |
| 116 | + |
| 117 | + - name: Set up Python |
| 118 | + uses: actions/setup-python@v2 |
| 119 | + with: |
| 120 | + python-version: '3.x' |
| 121 | + |
| 122 | + - name: Install dependencies |
| 123 | + run: | |
| 124 | + python -m pip install --upgrade pip |
| 125 | + pip install setuptools wheel twine |
| 126 | +
|
| 127 | + - name: Build and publish |
| 128 | + env: |
| 129 | + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 130 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 131 | + run: | |
| 132 | + python setup.py sdist bdist_wheel |
| 133 | + twine upload dist/* |
0 commit comments