|
| 1 | +name: Deploy to Staging |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + test: |
| 14 | + name: Test |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + actions: read |
| 19 | + checks: write |
| 20 | + pull-requests: write |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + python-version: ["3.8"] |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + - name: Set up Python ${{ matrix.python-version }} |
| 29 | + id: python-setup |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: ${{ matrix.python-version }} |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + python -m venv .venv |
| 37 | + .venv/bin/pip install pytest |
| 38 | + .venv/bin/pip install -r app/requirements.txt |
| 39 | +
|
| 40 | +
|
| 41 | + - name: Lint with flake8 |
| 42 | + run: | |
| 43 | + source .venv/bin/activate |
| 44 | + .venv/bin/pip install flake8 |
| 45 | + # stop the build if there are Python syntax errors or undefined names |
| 46 | + flake8 ./app --count --select=E9,F63,F7,F82 --show-source --statistics |
| 47 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 48 | + flake8 ./app --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 49 | +
|
| 50 | + - name: Run tests |
| 51 | + if: always() |
| 52 | + run: | |
| 53 | + source .venv/bin/activate |
| 54 | + pytest --junit-xml=./reports/pytest.xml --tb=auto -v |
| 55 | +
|
| 56 | + - name: Upload test results |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + if: always() |
| 59 | + with: |
| 60 | + name: test-results-${{ matrix.python-version }} |
| 61 | + path: ./reports/pytest.xml |
| 62 | + if-no-files-found: warn |
| 63 | + deploy: |
| 64 | + needs: test |
| 65 | + uses: lambda-feedback/evaluation-function-workflows/.github/workflows/deploy.yml@deploy-request |
| 66 | + with: |
| 67 | + template-repository-name: "lambda-feedback/evaluation-function-boilerplate-python" |
| 68 | + build-file: "app/Dockerfile" |
| 69 | + build-context: "./app" |
| 70 | + build-platforms: "aws" |
| 71 | + environment: "staging" |
| 72 | + lfs: false |
| 73 | + secrets: |
| 74 | + aws-key-id: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_ID }} |
| 75 | + aws-secret-key: ${{ secrets.LAMBDA_CONTAINER_PIPELINE_AWS_SECRET}} |
| 76 | + function-admin-api-key: ${{ secrets.FUNCTION_ADMIN_API_KEY}} |
| 77 | + gcp_credentials: ${{ secrets.GCP_DEPLOY }} |
0 commit comments