-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from anaconda/chore/ci-and-pkg
[chore] CI and packaging
- Loading branch information
Showing
9 changed files
with
6,314 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: "release" | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
|
||
publish-conda-pkg-to-anaconda-dot-org: | ||
name: Publish conda package to Anaconda.org | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' # Only run on push to main branch | ||
needs: [test] | ||
steps: | ||
- name: Retrieve the source code | ||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Create build environment | ||
run: | | ||
source $CONDA/bin/activate | ||
conda create -n build --file ./etc/build.linux-64.lock | ||
- name: Download the build artifacts | ||
uses: actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395 # v4 | ||
with: | ||
name: anaconda-cli-base-conda-${{ github.sha }} | ||
path: ~/anaconda-cli-base-conda-bld | ||
- name: publish | ||
env: | ||
TOKEN: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} | ||
run: | | ||
source $CONDA/bin/activate && conda activate build | ||
[[ "$GITHUB_REF" =~ ^refs/tags/v ]] || export LABEL="--label dev" | ||
anaconda --verbose \ | ||
--token $TOKEN \ | ||
upload \ | ||
--user anaconda-cloud \ | ||
$LABEL \ | ||
--force \ | ||
~/anaconda-cli-base-conda-bld/noarch/anaconda-cli-base-* | ||
publish-wheel-to-anaconda-dot-org: | ||
name: Publish wheel to Anaconda.org | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' # Only run on push to main branch | ||
needs: [test] | ||
steps: | ||
- name: Retrieve the source code | ||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Download the build artifacts | ||
uses: actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395 # v4 | ||
with: | ||
name: anaconda-cli-base-wheel-${{ github.sha }} | ||
path: ~/dist | ||
- name: Create build environment | ||
run: | | ||
source $CONDA/bin/activate | ||
conda create -n build --file ./etc/build.linux-64.lock | ||
- name: Upload to anaconda.org | ||
env: | ||
TOKEN: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} | ||
GITHUB_REF: ${{ github.ref }} | ||
run: | | ||
source $CONDA/bin/activate && conda activate build | ||
[[ "$GITHUB_REF" =~ ^refs/tags/v ]] || export LABEL="--label dev" | ||
anaconda --verbose \ | ||
--token $TOKEN \ | ||
upload \ | ||
--user anaconda-cloud \ | ||
~/dist/*.whl \ | ||
--summary \ | ||
"A base CLI entrypoint supporting Anaconda CLI plugins" \ | ||
$LABEL \ | ||
--force \ | ||
publish-to-pypi: | ||
name: Build & publish to PyPI | ||
if: startsWith(github.event.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 | ||
- name: Download the build artifacts | ||
uses: actions/download-artifact@9c19ed7fe5d278cd354c7dfd5d3b88589c7e2395 # v4 | ||
with: | ||
name: anaconda-cli-base-wheel-${{ github.sha }} | ||
path: ~/dist | ||
- name: Install build dependencies | ||
run: pip install twine | ||
- name: Upload to PyPI with twine | ||
run: python -m twine upload ~/dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: "test" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
merge_group: | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
name: Python ${{ matrix.python-version }} | ||
runs-on: | ||
labels: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install testing dependencies | ||
run: python -m pip install tox tox-gh-actions | ||
- name: Test with tox | ||
run: tox | ||
|
||
build-conda-package: | ||
name: Build conda package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Create build environment | ||
run: | | ||
source $CONDA/bin/activate | ||
conda create -n build --file ./etc/build.linux-64.lock | ||
- name: conda build | ||
run: | | ||
source $CONDA/bin/activate && conda activate build | ||
mkdir -p ./conda-bld | ||
VERSION=`hatch version` conda build -c conda-forge -c defaults --override-channels conda.recipe --output-folder ./conda-bld | ||
- name: Upload the build artifact | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 | ||
with: | ||
name: anaconda-cli-base-conda-${{ github.sha }} | ||
path: ./conda-bld | ||
if-no-files-found: error | ||
retention-days: 7 | ||
|
||
build-wheel: | ||
name: Build the wheel | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Python | ||
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Install build dependencies | ||
run: pip install build | ||
- name: Build the package | ||
run: python -m build | ||
- name: Upload the build artifact | ||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 | ||
with: | ||
name: anaconda-cli-base-wheel-${{ github.sha }} | ||
path: dist/* | ||
if-no-files-found: error | ||
retention-days: 7 | ||
|
||
# This check job runs to ensure all tests and builds have passed, such that we can use it as a "wildcard" | ||
# for branch protection to ensure all tests pass before a PR can be merged. | ||
check: | ||
name: Check all tests passed | ||
if: always() | ||
needs: [test, build-conda-package, build-wheel] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Decide whether all required jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Distribution / packaging | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
*.egg-info | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.coverage | ||
.coverage.* | ||
coverage.xml | ||
.pytest_cache/ | ||
.tox/ | ||
|
||
# Documentation | ||
docs/_build/ | ||
docs/.cache/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# vscode ide stuff | ||
*.code-workspace | ||
.history | ||
.vscode | ||
|
||
# Version file generated by setuptools-scm | ||
src/*/_version.py | ||
|
||
# Stored tokens (for dev) | ||
/tokens.json |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Command aliases | ||
CONDA_EXE ?= conda | ||
CONDA_LOCK := $(CONDA_EXE)-lock | ||
|
||
name = $(word 1, $(subst ., ,$1)) | ||
|
||
ENVIRONMENT_YMLS = $(wildcard *.environment.yml) | ||
ENVIRONMENTS := $(foreach e,$(wildcard *.environment.yml),$(call name, $e)) | ||
LOCKFILES := $(foreach e, $(ENVIRONMENTS), $e.conda-lock.yml) | ||
# Explicit lockfiles are used in github actions with conda-incubator/setupminiconda | ||
EXPLICIT_LOCKFILES := $(foreach e, $(ENVIRONMENTS), $e.linux-64.lock) | ||
|
||
help: ## Display help on all Makefile targets | ||
@@grep -h '^[a-zA-Z]' $(MAKEFILE_LIST) | awk -F ':.*?## ' 'NF==2 {printf " %-20s%s\n", $$1, $$2}' | sort | ||
|
||
.PHONY: $(ENVIRONMENTS) | ||
$(ENVIRONMENTS): ## Lock this specific environment.yml file | ||
rm -f $@.conda-lock.yml | ||
rm -f $@.linux-64.lock | ||
$(CONDA_LOCK) lock -f $@.environment.yml --lockfile $@.conda-lock.yml | ||
$(CONDA_LOCK) render -p linux-64 --filename-template "$@.{platform}.lock" $@.conda-lock.yml | ||
|
||
lock: $(ENVIRONMENTS) ## lock all .environment.yml files | ||
|
||
clean: ## Remove lockfiles and explicit files | ||
rm $(LOCKFILES) | ||
rm $(EXPLICIT_LOCKFILES) |
Oops, something went wrong.