· 4 years ago · Nov 21, 2020, 11:10 AM
1# This workflow will install Python dependencies, run tests and lint with a single version of Python
2# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
4name: API Tests
5
6on: ["push", "pull_request"]
7jobs:
8 build:
9
10 runs-on: ubuntu-latest
11
12 steps:
13 - uses: actions/checkout@v2
14 - uses: actions/setup-python@v2
15 with:
16 python-version: 3.7.9
17
18 - name: Run image
19 uses: abatilo/actions-poetry@v2.0.0
20 with:
21 poetry-version: 1.1.2
22
23 - name: Install
24 run: poetry install
25
26 - name: Run pytest
27 env:
28 MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
29 MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
30 SECRET_KEY: ${{ secrets.SECRET_KEY }}
31 VK_CLIENT_ID: ${{ secrets.VK_CLIENT_ID }}
32 VK_CLIENT_SECRET: ${{ secrets.VK_CLIENT_SECRET }}
33 DEBUG: False
34 run: poetry run python -m py.test --cov-report xml --cov=app
35
36 - name: Codacy Reporter
37 env:
38 CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
39 run: poetry run bash <(curl -Ls https://coverage.codacy.com/get.sh) report
40
41 create_image:
42 if: startsWith(github.ref, 'refs/tags/v')
43 runs-on: ubuntu-latest
44 needs: build
45 steps:
46 - uses: actions/checkout@v2
47 - name: Setup QEMU
48 uses: docker/setup-qemu-action@v1
49
50 - name: Set up Docker Buildx
51 uses: docker/setup-buildx-action@v1
52
53 - name: Login to GitHub Container Registry
54 uses: docker/login-action@v1.3.0
55 with:
56 registry: ghcr.io
57 username: ${{ github.repository_owner }}
58 password: ${{ secrets.CR_PAT }}
59
60 - name: Get the version
61 id: vars
62 run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
63 - name: Build and push
64 id: docker_build
65 uses: docker/build-push-action@v2
66 with:
67 context: .
68 file: ./Dockerfile
69 push: true
70 tags: followydev/followyapi:${{steps.vars.outputs.tag}}
71
72 - name: Image digest
73 run: echo ${{ steps.docker_build.outputs.digest }}
74