Skip to content

Commit

Permalink
CI: move conda build test to seperate job (nebari-dev#2073)
Browse files Browse the repository at this point in the history
Co-authored-by: eskild <[email protected]>
  • Loading branch information
fangchenli and iameskild authored Oct 18, 2023
1 parent 20bc7d4 commit ee1b4c9
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 76 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- "3.11"
fail-fast: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.python-version }}
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-${{ matrix.python-version }}
cancel-in-progress: true
steps:
- name: "Checkout Infrastructure"
Expand All @@ -54,10 +54,6 @@ jobs:
channels: conda-forge,defaults
activate-environment: nebari-dev

- name: Install conda-build
run: |
conda install --quiet --yes conda-build
- name: Install Nebari
run: |
python --version
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test_aws_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
- name: Install Nebari
run: |
pip install .[dev]
conda install --quiet --yes conda-build
playwright install
- name: Retrieve secret from Vault
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/test_conda_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Test Conda Build"

on:
pull_request:
paths:
- ".github/workflows/test_conda_build.yaml"
- "pyproject.toml"
push:
branches:
- main
- develop
- release/\d{4}.\d{1,2}.\d{1,2}
paths:
- ".github/workflows/test_conda_build.yaml"
- "pyproject.toml"

jobs:
test-conda-build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- name: "Checkout Infrastructure"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.8
channels: conda-forge
activate-environment: nebari-dev

- name: Install dependencies
run: |
conda install build grayskull conda-build
- name: Generate sdist
run: |
python -m build --sdist
- name: Generate meta.yaml
run: |
python -m grayskull pypi dist/*.tar.gz
- name: Build conda package
run: |
conda build nebari
1 change: 0 additions & 1 deletion .github/workflows/test_do_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
- name: Install Nebari
run: |
pip install .[dev]
conda install --quiet --yes conda-build
playwright install
- name: Retrieve secret from Vault
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test_gcp_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
- name: Install Nebari
run: |
pip install .[dev]
conda install --quiet --yes conda-build
playwright install
- name: Retrieve secret from Vault
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ dev = [
"pytest-playwright",
"pytest-cov",
"coverage[toml]",
"grayskull",
"build",
"jinja2",
"setuptools==63.4.3",
]
Expand Down
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ addopts =
# turn warnings into errors
-Werror
markers =
conda: conda required to run this test (deselect with '-m \"not conda\"')
gpu: test gpu working properly
preemptible: test preemptible instances
testpaths =
Expand Down
65 changes: 0 additions & 65 deletions tests/tests_unit/test_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,7 @@
import subprocess
import urllib
from pathlib import Path

import pytest

from _nebari.provider import terraform

SRC_DIR = Path(__file__).parent.parent.parent
PYPROJECT = SRC_DIR / "pyproject.toml"


@pytest.mark.conda
def test_build_by_conda_forge(tmp_path):
"""
This test ensures that nebari can be built and packaged by conda-forge.
This is achieved by walking through the following steps:
1. Use Python build package to generate the `sdist` .tar.gz file
2. Use grayskull package to generate the `meta.yaml` recipe file
3. Use conda build to attempt to build the nebari package from the `meta.yaml`
These steps mimic what takes places on the conda-forge/nebari-feedstock repo whenever
a new version of the package gets released.
NOTE: this test requires conda and conda-build
"""

assert PYPROJECT.exists()

try:
# build sdist
subprocess.run(
["python", "-m", "build", SRC_DIR, "--outdir", tmp_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)

# get location of sdist file built above
sdist_loc = next(tmp_path.glob("*.tar.gz"))
# run grayskull to create the meta.yaml using the local sdist file
subprocess.run(
[
"grayskull",
"pypi",
"--strict-conda-forge",
sdist_loc,
"--output",
tmp_path,
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)

# get the directory the meta.yaml is in
meta_loc = tmp_path / "nebari"
# try to run conda build to build package from meta.yaml
subprocess.run(
["conda", "build", "--channel=conda-forge", meta_loc],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)
except subprocess.CalledProcessError as e:
print(e.stderr.decode("utf-8"))
raise e


def test_terraform_open_source_license():
tf_version = terraform.version()
Expand Down

0 comments on commit ee1b4c9

Please sign in to comment.