Skip to content

Bump autodoc-pydantic from 1.6.1 to 2.0.1 #226

Bump autodoc-pydantic from 1.6.1 to 2.0.1

Bump autodoc-pydantic from 1.6.1 to 2.0.1 #226

Workflow file for this run

name: CI/CD Pull Requests
on:
pull_request:
types: [ opened, synchronize, reopened ]
concurrency:
group: ${{ github.head_ref }}
jobs:
# Inspect the information that is accessible in each context
# https://docs.github.com/en/actions/learn-github-actions/contexts#example-printing-context-information-to-the-log-file
# You can delete this section
jobinfo:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJSON(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJSON(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJSON(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
run: echo "$MATRIX_CONTEXT"
# Check linting
lint:
runs-on: ubuntu-latest
name: "Lint"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: lint-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements**.txt') }}
- name: Install requirements
run: |
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt -e .
- name: flake8 Lint
uses: reviewdog/action-flake8@v3
with:
github_token: ${{ github.token }}
# Checks if all tests pass
test:
runs-on: ubuntu-latest
name: "Test"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: test-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('requirements**.txt') }}
- name: Install requirements
run: |
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt -e .
- name: Run tests
run: |
pytest --cov=./ensysmod --cov-report=xml --junitxml="result.xml" ./tests
- name: Upload tests results
uses: actions/upload-artifact@v3
if: always()
with:
name: test-results
path: |
coverage.xml
result.xml
uplaod_coverage_results:
needs: test
runs-on: ubuntu-latest
name: "Upload code coverage"
if: ${{ always() && github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download tests results
uses: actions/download-artifact@v2
with:
name: test-results
- name: Check files
run: |
cat ./coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2.1.0
with:
flags: pytest
fail_ci_if_error: true
publish_test_results:
needs: test
runs-on: ubuntu-latest
name: "Publish unit test results"
if: ${{ always() && github.actor != 'dependabot[bot]' }}
steps:
- name: Download tests results
uses: actions/download-artifact@v2
with:
name: test-results
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: result.xml
report_individual_runs: true
comment_mode: "always"
build_pr_image:
needs: [ test, lint ]
runs-on: ubuntu-latest
name: "Build preview image"
if: ${{ success() && github.actor != 'dependabot[bot]' }}
outputs:
image_tag: ${{ steps.get_tag.outputs.DOCKER_TAG }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Get tag for docker image
id: get_tag
run: |
DOCKER_TAG=ghcr.io/${{ github.repository }}:pr-${{ github.event.number }}
DOCKER_TAG=${DOCKER_TAG,,}
echo ::set-output name=DOCKER_TAG::"${DOCKER_TAG}"
- name: Build the Docker image
run: |
docker build . --tag ${{ steps.get_tag.outputs.DOCKER_TAG }}
- name: Push the Docker image to GitHub Container Registry
run: |
docker push ${{ steps.get_tag.outputs.DOCKER_TAG }}
deploy_pr:
needs: [ build_pr_image ]
runs-on: ubuntu-latest
concurrency: ssh-connection # only one ssh connection at a time
name: "Deploy preview image"
if: ${{ success() && github.actor != 'dependabot[bot]' }}
steps:
- name: Update deployment status - start
uses: bobheadxi/deployments@v1.4.0
id: deployment
with:
step: start
token: ${{ github.token }}
env: PR-${{ github.event.number }}-Preview
no_override: false
desc: "Preview deployment for PR #${{ github.event.number }}"
ref: ${{ github.head_ref }}
transient: true
- name: Install VPN
run: |
sudo /sbin/modprobe tun
sudo apt install openconnect
- name: Connect VPN
run: |
echo "${{ secrets.VPN_PASS }}" | sudo openconnect ${{ secrets.VPN_URL }} --background --user=${{ secrets.VPN_USER }} --passwd-on-stdin
- name: Deploy docker container on private server
uses: appleboy/ssh-action@v0.1.4
with:
host: ${{ secrets.SSH_URL }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASS }}
script: |
docker system prune -af
docker pull ${{ needs.build_pr_image.outputs.image_tag }}
docker ps --filter publish=$((9000 + ${{ github.event.number }}))
docker rm -f $(docker ps --filter publish=$((9000 + ${{ github.event.number }})) -aq)
docker run -d -p $((9000 + ${{ github.event.number }})):8080 --name "pr-preview-$((9000 + ${{ github
.event.number }}))" ${{ needs.build_pr_image.outputs.image_tag }}
- name: Disconnect VPN
if: ${{ always() }}
run: |
sudo pkill openconnect
- name: Get env url
id: get_env_url
run: |
ENV_URL="http://${{ secrets.SSH_URL }}:$((9000 + ${{ github.event.number }} ))"
echo ::set-output name=ENV_URL::"${ENV_URL}"
- name: Update deployment status - finish
uses: bobheadxi/deployments@v1.4.0
if: always()
with:
step: finish
token: ${{ github.token }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.get_env_url.outputs.env_url }}