|
1 | | -name: Build |
| 1 | +# |
| 2 | +# Main workflow to build and release |
| 3 | + |
| 4 | +name: Main |
| 5 | + |
| 6 | +# |
| 7 | +# Operational Variables |
| 8 | + |
| 9 | +env: |
| 10 | + MAJOR: 0 |
| 11 | + MINOR: 0 |
| 12 | + PYTHON_VERSION: 3.9.6 |
| 13 | + |
| 14 | +# |
| 15 | +# Establish when the workflow is run |
2 | 16 |
|
3 | 17 | on: |
4 | | - push: |
5 | | - branches: [ main, develop ] |
6 | | - pull_request: |
7 | | - branches: [ main ] |
| 18 | + push: {} |
| 19 | + pull_request: {} |
| 20 | + |
| 21 | +# |
| 22 | +# Workflow |
8 | 23 |
|
9 | 24 | jobs: |
10 | | - build: |
11 | 25 |
|
| 26 | + build: |
12 | 27 | runs-on: ubuntu-latest |
13 | | - strategy: |
14 | | - matrix: |
15 | | - python-version: [3.9] |
16 | | - |
17 | 28 | steps: |
18 | | - - uses: actions/checkout@v2 |
19 | | - - name: Set up Python ${{ matrix.python-version }} |
| 29 | + |
| 30 | + - name: Determine whether this is a release build |
| 31 | + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.base_ref == 'refs/heads/main' }} |
| 32 | + env: |
| 33 | + IS_RELEASE: "true" |
| 34 | + run: echo "We will be performing a release upon success" |
| 35 | + |
| 36 | + - name: Checkout out our code |
| 37 | + uses: actions/checkout@v2 |
| 38 | + |
| 39 | + - name: Set up Python ${{ env.PYTHON_VERSION }} |
20 | 40 | uses: actions/setup-python@v2 |
21 | 41 | with: |
22 | | - python-version: ${{ matrix.python-version }} |
| 42 | + python-version: ${{ env.PYTHON_VERSION }} |
| 43 | + |
23 | 44 | - name: Install dependencies |
24 | 45 | run: | |
25 | 46 | python -m pip install --upgrade pip |
26 | 47 | pip install -r requirements.txt |
27 | 48 | pip install -r test-requirements.txt |
28 | | - - name: Lint with flake8 |
29 | | - run: | |
30 | | - # stop the build if there are Python syntax errors or undefined names |
31 | | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
32 | | - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
33 | | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
34 | | - - name: Lint with pylint |
| 49 | +
|
| 50 | + - name: Lint |
35 | 51 | run: | |
| 52 | + flake8 --statistics |
36 | 53 | pylint mrmat_python_api_flask |
37 | | - - name: Install locally |
| 54 | +
|
| 55 | + - name: Test |
38 | 56 | run: | |
39 | 57 | python ./setup.py install |
40 | | - - name: Test with pytest |
41 | | - run: | |
42 | | - python -m pytest --junitxml=build/test-results-${{ matrix.python-version }}.xml |
43 | | - - name: Upload pytest test results |
| 58 | + python -m pytest |
| 59 | +
|
| 60 | + - name: Upload test results |
44 | 61 | uses: actions/upload-artifact@v2 |
45 | | - with: |
46 | | - name: pytest-results-${{ matrix.python-version }} |
47 | | - path: build/test-results-${{ matrix.python-version }}.xml |
48 | | - # Use always() to always run this step to publish test results when there are test failures |
49 | 62 | if: ${{ always() }} |
| 63 | + with: |
| 64 | + name: tests |
| 65 | + path: build/junit.xml |
| 66 | + |
50 | 67 | - name: Upload coverage |
51 | 68 | uses: actions/upload-artifact@v2 |
52 | 69 | with: |
53 | 70 | name: coverage |
54 | 71 | path: build/coverage.xml |
| 72 | + |
| 73 | + - name: Conditionally perform a release |
| 74 | + if: ${{ env.IS_RELEASE == 'true' }} |
| 75 | + uses: elgohr/Github-Release-Action@master |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
| 78 | + with: |
| 79 | + args: Creating release |
0 commit comments