diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..9caf9e8 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +max-line-length = 99 +ignore = F401, W503 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..b230f4c --- /dev/null +++ b/.github/release-drafter.yml @@ -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 diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 0000000..069e89a --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,15 @@ +name: Draft Release + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Release Drafter + uses: release-drafter/release-drafter@v5.12.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..3cc95d4 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -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}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..6e70cd3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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/* diff --git a/.gitignore b/.gitignore index 10b1f78..3e4d214 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,5 @@ cover/ profile_default/ ipython_config.py +# pyenv +.python-version diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8cbb9f3 --- /dev/null +++ b/Makefile @@ -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/* diff --git a/requirements-dev.txt b/requirements-dev.txt index 0cdff57..b7dd57b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 \ No newline at end of file +recommonmark >= 0.7.1