Skip to content

CI

CI #3051

Workflow file for this run

name: CI
on:
push:
branches: [master]
tags: [v*.*, v*.*.*]
pull_request:
branches: [master]
pull_request_target:
branches: [master]
schedule:
- cron: 0 4 * * *
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
if: |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
steps:
- name: Checkout commit
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Cache packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
- name: Install dependencies
run: make setup
- name: Lint
run: |
echo "::add-matcher::.github/actionlint-matcher.json"
make lint
- name: Run unit tests
run: make test_unit
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .coverage-unit.xml
flags: unit
name: codecov-unit
- name: Install containerd
run: |
# without containerd, tests TestTopApi won't work
# see https://github.com/neuromation/platform-api/pull/928/files#diff-1d37e48f9ceff6d8030570cd36286a61R76
export DEBIAN_FRONTEND=noninteractive
export RELEASE=$(lsb_release -cs)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository -y \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $RELEASE stable"
sudo apt-get -q update
sudo apt-get -q install -y \
docker-ce=5:20.10.24~3-0~ubuntu-$RELEASE \
docker-ce-cli=5:20.10.24~3-0~ubuntu-$RELEASE \
containerd.io=1.6.20-1
- name: Start minikube
run: |
make install_k8s
make start_k8s
- name: Login to ghcr.io
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Pull test images
run: make docker_pull_test_images
- name: Setup services in minikube
run: |
make apply_configuration_k8s
make test_k8s
- name: Run integration tests
run: |
make test_integration
make test_integration_minikube
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .coverage-integration.xml
flags: integration
name: codecov-integration
- name: Build Docker image
run: make docker_build
env:
IMAGE_TAG: latest
- name: Upload image artifact
uses: neuro-inc/[email protected]
with:
image: platformmonitoringapi
token: ${{ secrets.GITHUB_TOKEN }}
release:
name: Create release
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: neuro-inc/reuse/.github/workflows/[email protected]
with:
image: platformmonitoringapi
helm_charts: platform-monitoring
deploy_dev:
name: Deploy on dev
needs: release
uses: neuro-inc/reuse/.github/workflows/[email protected]
with:
helm_charts: platform-monitoring
version: ${{ needs.release.outputs.version }}