Skip to content

Commit

Permalink
Merge pull request #4 from nasa/harmony-833
Browse files Browse the repository at this point in the history
HARMONY-833: Actions for tests, and drafting and publishing releases
  • Loading branch information
bilts authored May 6, 2021
2 parents e7b8089 + eac9820 commit 921efc8
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 99
ignore = F401, W503
15 changes: 15 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
$CHANGES
15 changes: 15 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Draft Release

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Release Drafter
uses: release-drafter/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Release

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- shell: bash
env:
REPO_PASS: ${{ secrets.PYPI }}
VERSION_TAG: ${{ github.event.release.tag_name }}
BRANCH: ${{ github.event.release.target_commitish }}
run: |
VERSION=$(echo "${VERSION_TAG}" | cut -c2-) make build
make publish
# Setup git
# https://api.github.com/users/github-actions%5Bbot%5D
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Commit and push updated release files
git checkout -b "${BRANCH}"
git add .
git commit -m "Update release version to ${VERSION_TAG}"
git push origin "${BRANCH}"
git tag --force "${VERSION_TAG}"
git push --force origin "${VERSION_TAG}"
39 changes: 39 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Tests

# More conservative about duplicate tests due to tests accessing real files
on: [pull_request]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- uses: extractions/netrc@v1
with:
machine: uat.urs.earthdata.nasa.gov
username: ${{ secrets.EDL_USER }}
password: ${{ secrets.EDL_PASSWORD }}

- name: Install dependencies
run: |
make install
- name: Tests
run: |
make ci
- name: Archive code coverage results
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
path: htmlcov/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ cover/
profile_default/
ipython_config.py

# pyenv
.python-version
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.PHONY: venv-setup pyenv-setup install install-examples clean examples lint test test-watch ci docs
.SILENT: virtualenv

VERSION ?= $(shell git describe --tags | sed 's/-/\+/' | sed 's/-/\./g')
REPO ?= https://upload.pypi.org/legacy/
REPO_USER ?= __token__
REPO_PASS ?= unset

venv-setup:
python -m venv .venv

pyenv-setup:
if ! type pyenv > /dev/null; \
then \
echo "\nUnable to create virtualenv: pyenv not found. Please install pyenv & pyenv-virtualenv."; \
echo " See:"; \
echo " https://github.com/pyenv/pyenv"; \
echo " https://github.com/pyenv/pyenv-virtualenv"; \
exit; \
else \
pyenv install 3.9.1; \
pyenv virtualenv 3.9.1 zarr-eosdis-store; \
pyenv activate zarr-eosdis-store; \
fi

clean:
coverage erase
rm -rf htmlcov
rm -rf build dist *.egg-info || true

clean-docs:
cd docs && $(MAKE) clean

install:
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt

lint:
flake8 eosdis_store --show-source --statistics

test:
coverage run -m pytest

ci: test
coverage html

build: clean
sed -i.bak "s/__version__ .*/__version__ = \"$(VERSION)\"/" eosdis_store/VERSION.py && rm eosdis_store/version.py.bak
python -m pip install --upgrade --quiet setuptools wheel twine
python setup.py --quiet sdist bdist_wheel

publish: build
python -m twine check dist/*
python -m twine upload --username "$(REPO_USER)" --password "$(REPO_PASS)" --repository-url "$(REPO)" dist/*
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pytest~=5.4
flake8~=3.8
safety >= 1.8.5
coverage >= 4.5.4
pygments ~= 2.9
sphinx >= 3.2.1
sphinx-rtd-theme >= 0.5.0
recommonmark >= 0.6.0
recommonmark >= 0.7.1

0 comments on commit 921efc8

Please sign in to comment.