|
| 1 | +name: Build, Test and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + fossa: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v3 |
| 13 | + - name: Set up Python ${{ matrix.python-version }} |
| 14 | + uses: actions/setup-python@v4 |
| 15 | + with: |
| 16 | + python-version: 3.x |
| 17 | + cache: 'pip' |
| 18 | + cache-dependency-path: | |
| 19 | + **/setup.cfg |
| 20 | + **/requirements*.txt |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + python -m pip install --upgrade pip |
| 24 | + python -m pip install -r requirements.txt |
| 25 | + pip install setuptools wheel twine |
| 26 | + - name: Build |
| 27 | + run: python setup.py sdist bdist_wheel |
| 28 | + - name: Run FOSSA scan and upload build data |
| 29 | + uses: fossas/fossa-action@main |
| 30 | + with: |
| 31 | + api-key: ${{ secrets.FOSSA_API_KEY }} |
| 32 | + branch: ${{ github.ref_name }} |
| 33 | + - name: Run FOSSA tests |
| 34 | + uses: fossas/fossa-action@main |
| 35 | + with: |
| 36 | + api-key: ${{ secrets.FOSSA_API_KEY }} |
| 37 | + run-tests: true |
| 38 | + |
| 39 | + snyk: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v3 |
| 43 | + - name: Set up Python |
| 44 | + uses: actions/setup-python@v4 |
| 45 | + with: |
| 46 | + python-version: 3.x |
| 47 | + cache: 'pip' |
| 48 | + cache-dependency-path: | |
| 49 | + **/setup.cfg |
| 50 | + **/requirements*.txt |
| 51 | + - name: Install dependencies |
| 52 | + run: | |
| 53 | + python -m pip install --upgrade pip |
| 54 | + python -m pip install -r requirements.txt |
| 55 | + pip install setuptools wheel twine |
| 56 | + - name: Build |
| 57 | + run: python setup.py sdist bdist_wheel |
| 58 | + - name: Run Snyk to check for vulnerabilities |
| 59 | + env: |
| 60 | + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} |
| 61 | + run: | |
| 62 | + npm install -g snyk |
| 63 | + snyk auth $SNYK_TOKEN |
| 64 | + snyk monitor |
| 65 | +
|
| 66 | + test: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + strategy: |
| 69 | + fail-fast: false |
| 70 | + matrix: |
| 71 | + python-version: ["3.9", "3.10"] |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v3 |
| 74 | + - name: Set up Python ${{ matrix.python-version }} |
| 75 | + uses: actions/setup-python@v4 |
| 76 | + with: |
| 77 | + python-version: ${{ matrix.python-version }} |
| 78 | + cache: 'pip' |
| 79 | + cache-dependency-path: | |
| 80 | + **/setup.cfg |
| 81 | + **/requirements*.txt |
| 82 | + - name: Install dependencies |
| 83 | + run: | |
| 84 | + python -m pip install --upgrade pip |
| 85 | + python -m pip install -r test-requirements.txt |
| 86 | + - name: Test |
| 87 | + run: python -m unittest test/* |
| 88 | + - name: Flake8 on SDK |
| 89 | + run: python -m flake8 --ignore F401,E402,E501,W504 openfga_sdk |
| 90 | + - name: Flake8 on unit test |
| 91 | + run: python -m flake8 --ignore E501 test |
| 92 | + |
| 93 | + create-release: |
| 94 | + runs-on: ubuntu-latest |
| 95 | + if: startsWith(github.ref, 'refs/tags/v') |
| 96 | + needs: [test, fossa, snyk] |
| 97 | + |
| 98 | + steps: |
| 99 | + - uses: actions/checkout@v3 |
| 100 | + |
| 101 | + - uses: Roang-zero1/github-create-release-action@5cf058ddffa6fa04e5cda07c98570c757dc4a0e1 |
| 102 | + with: |
| 103 | + version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ |
| 104 | + env: |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments