Skip to content

Commit

Permalink
Merge pull request #169 from Anaconda-Platform/prep-224
Browse files Browse the repository at this point in the history
Back to arch packages
  • Loading branch information
mcg1969 authored Aug 4, 2020
2 parents 80fd0b5 + 9797e82 commit f3596a3
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 75 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/cleanup.yml

This file was deleted.

74 changes: 26 additions & 48 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,11 @@ on:
pull_request:
branches:
- master
defaults:
run:
shell: bash
jobs:
package:
runs-on: ubuntu-latest
steps:
- name: Retrieve the source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build the package
run: |
conda install -y conda-build conda-verify
conda build conda-recipe --no-test
- name: Upload the build artifact
uses: actions/upload-artifact@v2
with:
name: package-${{ github.sha }}
path: /usr/share/miniconda/conda-bld
testbed:
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -61,16 +45,13 @@ jobs:
# The argument tells the script we are in caching mode
run: testbed/build.sh
tests:
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
needs: [testbed,package]
needs: testbed
strategy:
fail-fast: false
matrix:
os: [macos-latest,ubuntu-latest,windows-latest]
pyver: [3.6,3.7,3.8,2.7]
pyver: [2.7,3.6,3.7,3.8]
steps:
- name: Retrieve the source code
uses: actions/checkout@v2
Expand All @@ -90,44 +71,41 @@ jobs:
key: testbed-${{ matrix.os }}-${{ hashFiles('testbed') }}
- name: Verify or build the testbed
run: testbed/build.sh
- name: Download the build artifact
uses: actions/download-artifact@v2
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Create the test environment
run: |
mkdir -p ~/.conda
mv conda-bld $CONDA_ROOT/conda-bld
echo $CONDA_ROOT/ext1/ext2/env/test_env1 > ~/.conda/environments.txt
source $CONDA_ROOT/etc/profile.d/conda.sh
[ "${{ matrix.pyver }}" == "2.7" ] && BACKPORT="backports.functools_lru_cache"
conda create -y -n ptest local::nb_conda_kernels python=${{ matrix.pyver }} pytest pytest-cov requests mock $BACKPORT
- name: Test the package
- name: Build and test the package
run: |
source $CONDA_ROOT/etc/profile.d/conda.sh
conda activate ptest
[ "$RUNNER_OS" == "Windows" ] && export PYTHONIOENCODING=UTF-8
pytest -vs --cov=nb_conda_kernels tests | tee pytest.log
conda build conda-recipe --python=${{ matrix.pyver }} | tee build.log
# Because Windows refuses to preserve the error code
if grep ' FAILED ' pytest.log; then exit -1; fi
mv $CONDA_ROOT/conda-bld .
- name: Upload the build artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v2
with:
# By uploading to the same artifact we can download all of the packages
# and upload them all to anaconda.org in a single job
name: package-${{ github.sha }}
path: conda-bld/*/*.tar.bz2
upload:
needs: tests
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: tests
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
steps:
- name: Download the build artifact
- name: Retrieve the source code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download the build artifacts
uses: actions/download-artifact@v2
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Upload to anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
source /usr/share/miniconda/etc/profile.d/conda.sh
conda activate
conda install anaconda-client
source $CONDA/bin/activate
conda install -y anaconda-client
git tag describe --exact-match --tags HEAD || export LABEL="--label dev"
anaconda --verbose --token $ANACONDA_TOKEN upload --user jupycon $LABEL conda-bld/*/*.tar.bz2 --force
- name: Clean up older artifacts
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,32 @@ To set it in jupyter config file, edit the jupyter configuration file (py or jso
[Miniconda](https://conda.io/miniconda.html). If you are
on Windows, make sure you have a Bash shell on your path.

2. Create a testbed environment by running
2. Create and activate the testbed environment by running

```shell
bash testbed/build.sh
source testbed/build.sh
```

This performs the following steps:
- Builds a new root conda environment in `./conda`,
or in `CONDA_ROOT` if that environment variable is defined
- Builds a new root conda environment in `../nbckdev`,
or in `CONDA_ROOT` if that environment variable is defined.
(Note that the default directory `../nbckdev` is at the same
level as your copy of the repository. This is because we do
not want `conda build` to try to capture the entire testbed
into the build workspace.)
- Installs conda-build and the necessary dependencies to
locally test the package
- Installs the package in development mode
- Creates a set of environments that the test scripts
require to fully exercise the package.
- Activates the environment.

3. To test the package, activate this environment and run pytest.
If the environment already exists, `testbed/build.sh` will
quickly exit, so it is safe to run it if you are not sure.

3. Run pytest to test the package.

```shell
source conda/bin/activate
pytest tests
```

Expand Down
9 changes: 9 additions & 0 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
%PYTHON% -m pip install --no-deps --ignore-installed .
if errorlevel 1 exit 1

set SCRIPTS="%PREFIX%\Scripts"
if not exist %SCRIPTS% mkdir %SCRIPTS%
if errorlevel 1 exit 1

copy %SRC_DIR%\conda-recipe\post-link.bat %SCRIPTS%\.nb_conda_kernels-post-link.bat || exit 1
copy %SRC_DIR%\conda-recipe\pre-unlink.bat %SCRIPTS%\.nb_conda_kernels-pre-unlink.bat || exit 1
11 changes: 11 additions & 0 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$PYTHON -m pip install --no-deps --ignore-installed .

mkdir -p "$PREFIX"/bin

POST_LINK="$PREFIX"/bin/.nb_conda_kernels-post-link.sh
PRE_UNLINK="$PREFIX"/bin/.nb_conda_kernels-pre-unlink.sh

cp "$SRC_DIR"/conda-recipe/post-link.sh "$POST_LINK"
cp "$SRC_DIR"/conda-recipe/pre-unlink.sh "$PRE_UNLINK"

chmod +x "$POST_LINK" "$PRE_UNLINK"
22 changes: 14 additions & 8 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,31 @@ source:

build:
number: 0
noarch: python
script:
- python -m pip install --no-deps --ignore-installed .

requirements:
host:
- python
- pip
run:
- python
- notebook >=4.2
- pywin32 # [win]
- jupyter_client >=4.2

test:
source_files:
- setup.cfg
- tests
requires:
- pip
- backports.functools_lru_cache # [py2k]
- pytest
- pytest-cov
- ipykernel
- notebook
- requests
- mock
commands:
- pip check
imports:
- nb_conda_kernels
- python -m nb_conda_kernels list # [py3k]
- python -m pytest -v --cov=nb_conda_kernels tests

about:
home: https://github.com/Anaconda-Platform/nb_conda_kernels
Expand Down
8 changes: 7 additions & 1 deletion testbed/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Determine the root location of the testbed
cwd=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
[ $CONDA_ROOT ] || CONDA_ROOT=${cwd%/*}/conda
[ $CONDA_ROOT ] || CONDA_ROOT=${cwd%/*/*}/nbckdev
mkdir -p $CONDA_ROOT
export CONDA_ROOT=$(cd $CONDA_ROOT && pwd)
echo "Testbed location: $CONDA_ROOT"
Expand All @@ -22,6 +22,12 @@ function finish {
# Exit quickly if the cached version is available. See the end of
# the script for the explanation why we do it this way
if [ -d $CONDA_ROOT/conda-meta ]; then
# Make sure the external environment is in the environments.txt file
ext_env=$CONDA_ROOT/ext1/ext2/env/test_env1
if ! grep -q "^$ext_env" ~/.conda/environments.txt 2>/dev/null; then
mkdir -p ~/.conda
echo $ext_env >> ~/.conda/environments.txt
fi
source $CONDA_ROOT/etc/profile.d/conda.sh
conda activate base
finish
Expand Down

0 comments on commit f3596a3

Please sign in to comment.