CI #3209
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "CI" | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
pull_request_target: | |
branches: [master] | |
schedule: | |
- cron: 0 4 * * * | |
jobs: | |
lint: | |
if: | | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') | |
name: Linter | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Cache PyPI | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-py-3.9-${{ hashFiles('requirements/*.txt') }} | |
path: ${{ env.pythonLocation }} | |
- name: Cache pre-commit hooks | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: ${{ runner.os }}-pre-commit-python-3.9-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Install dependencies | |
run: | | |
python -m pip install -U pip | |
make setup | |
- name: Run linters | |
run: | | |
make lint | |
pretest: | |
if: | | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') | |
name: Prepare for tests | |
needs: [lint] | |
runs-on: ubuntu-latest | |
env: | |
PYTHONIOENCODING: utf-8 | |
NEURO_STAGING_URL: ${{ secrets.NEURO_STAGING_URL }} | |
NEURO_TOKEN: ${{ secrets.NEURO_TOKEN }} | |
NEURO_CLUSTER: default | |
NEURO_PROJECT: e2e-tests | |
NEURO_EXTRAS_PRESET: cpu-small | |
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299 | |
SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Setup Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Cache Python and its deps | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-py-3.9-${{ hashFiles('requirements/base.txt') }} | |
path: ${{ env.pythonLocation }} | |
- name: Install and configure neuro | |
run: | | |
python -m pip install -r requirements/base.txt | |
neuro config login-with-token ${{ env.NEURO_TOKEN }} ${{ env.NEURO_STAGING_URL }} | |
neuro config switch-cluster ${{ env.NEURO_CLUSTER }} | |
neuro config switch-project ${{ env.NEURO_PROJECT }} | |
neuro --color=no config show | |
- name: Login to ghcr.io | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build test image | |
run: | | |
export REPO_URL=https://github.com/neuro-inc/neuro-extras.git | |
export PACKAGE="git+$REPO_URL@$SHA" | |
docker build -t ghcr.io/neuro-inc/neuro-extras:$SHA \ | |
--build-arg NEURO_EXTRAS_PACKAGE=$PACKAGE . | |
- name: Push test image | |
run: | | |
docker push ghcr.io/neuro-inc/neuro-extras:$SHA | |
test: | |
if: | | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') || | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') | |
name: Run tests | |
needs: [pretest] | |
strategy: | |
matrix: | |
python-version: ['3.8', '3.9', '3.10', '3.11'] | |
os: [ubuntu, macos, windows] | |
exclude: | |
# not to overload the platform, we will remove this eventually | |
# see https://github.com/neuro-inc/neuro-extras/pull/249 | |
- python-version: 3.9 | |
os: macos | |
- python-version: 3.9 | |
os: windows | |
- python-version: 3.10 | |
os: macos | |
- python-version: 3.10 | |
os: windows | |
runs-on: ${{ matrix.os }}-latest | |
timeout-minutes: 90 | |
env: | |
PYTHONIOENCODING: utf-8 | |
steps: | |
- name: Checkout commit | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Authorize GCP | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.E2E_COOKIECUTTER_GCP_SA_KEY }} | |
- name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
export_default_credentials: true | |
- name: Configure AWS access | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.E2E_COOKIECUTTER_AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.E2E_COOKIECUTTER_AWS_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Install python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache Python and its deps | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-py-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'requirements/*.txt') }} | |
path: ${{ env.pythonLocation }} | |
- name: Cache pre-commit hooks | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: ${{ runner.os }}-pre-commit-python-${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Install libraries on Linux | |
if: matrix.os == 'ubuntu' | |
shell: bash | |
run: | | |
curl https://rclone.org/install.sh | sudo bash | |
- name: Install libraries on macOS | |
if: matrix.os == 'macos' | |
shell: bash | |
run: | | |
curl https://rclone.org/install.sh | sudo bash | |
- name: Install python dependencies | |
run: | | |
make setup | |
- name: Configure environment | |
env: | |
NEURO_STAGING_URL: ${{ secrets.NEURO_STAGING_URL }} | |
NEURO_TOKEN: ${{ secrets.NEURO_TOKEN }} | |
NEURO_CLUSTER: default | |
NEURO_PROJECT: e2e-tests | |
NEURO_EXTRAS_PRESET: cpu-small | |
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }} | |
run: | | |
neuro config login-with-token ${{ env.NEURO_TOKEN }} ${{ env.NEURO_STAGING_URL }} | |
neuro config switch-cluster ${{ env.NEURO_CLUSTER }} | |
neuro config switch-project ${{ env.NEURO_PROJECT }} | |
neuro --color=no config show | |
- name: Read PR labels | |
uses: joerick/[email protected] | |
id: pr_labels | |
- name: Run all tests | |
if: | | |
github.ref_type == 'branch' && github.ref_name == 'master' | |
env: | |
COLOR: 'yes' | |
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }} | |
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }} | |
NEURO_CLUSTER: default | |
#NEURO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed | |
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }} | |
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299 | |
SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
# Note: see tests/e2e/conftest.py:get_tested_archive_types() | |
PYTEST_DATA_COPY_ARCHIVE_TYPES: '.tar.gz' | |
PYTEST_PARALLEL: 6 | |
shell: bash | |
run: | | |
export NEURO_EXTRAS_IMAGE=ghcr.io/neuro-inc/neuro-extras:$SHA | |
make test | |
- name: Run smoke tests | |
if: | | |
!(github.ref_type == 'branch' && github.ref_name == 'master') | |
env: | |
COLOR: 'yes' | |
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }} | |
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }} | |
NEURO_CLUSTER: default | |
NEURO_EXTRAS_PRESET: cpu-small | |
#NEURO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed | |
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }} | |
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299 | |
SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
# Note: see tests/e2e/conftest.py:get_tested_archive_types() | |
PYTEST_DATA_COPY_ARCHIVE_TYPES: '.tar.gz' | |
PYTEST_PARALLEL: 6 | |
shell: bash | |
run: | | |
export NEURO_EXTRAS_IMAGE=ghcr.io/neuro-inc/neuro-extras:$SHA | |
make test_smoke | |
- name: Run data tests | |
if: | | |
!(github.ref_type == 'branch' && github.ref_name == 'master') && | |
contains(steps.pr_labels.outputs.labels, ' e2e-data ') | |
env: | |
COLOR: 'yes' | |
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }} | |
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }} | |
NEURO_CLUSTER: default | |
#NEURO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed | |
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }} | |
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299 | |
SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
# Note: see tests/e2e/conftest.py:get_tested_archive_types() | |
PYTEST_DATA_COPY_ARCHIVE_TYPES: '.tar.gz' | |
PYTEST_PARALLEL: 6 | |
shell: bash | |
run: | | |
export NEURO_EXTRAS_IMAGE=ghcr.io/neuro-inc/neuro-extras:$SHA | |
make test_data | |
- name: Run image tests | |
if: | | |
!(github.ref_type == 'branch' && github.ref_name == 'master') && | |
contains(steps.pr_labels.outputs.labels, ' e2e-image ') | |
env: | |
COLOR: 'yes' | |
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }} | |
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }} | |
NEURO_CLUSTER: default | |
NEURO_EXTRAS_PRESET: cpu-small | |
#NEURO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed | |
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }} | |
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299 | |
SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
# Note: see tests/e2e/conftest.py:get_tested_archive_types() | |
PYTEST_DATA_COPY_ARCHIVE_TYPES: '.tar.gz' | |
PYTEST_PARALLEL: auto | |
shell: bash | |
run: | | |
export NEURO_EXTRAS_IMAGE=ghcr.io/neuro-inc/neuro-extras:$SHA | |
make test_image |