From 8262afa8f97528350679f87404c8155d4f8ab4fb Mon Sep 17 00:00:00 2001 From: Patrick Quinn Date: Wed, 5 May 2021 15:09:07 -0400 Subject: [PATCH 1/4] HARMONY-833: Actions for tests, and drafting and publishing releases --- .flake8 | 3 ++ .github/release-drafter.yml | 15 ++++++++ .github/workflows/draft-release.yml | 15 ++++++++ .github/workflows/publish-release.yml | 38 +++++++++++++++++++ .github/workflows/tests.yml | 33 ++++++++++++++++ .gitignore | 2 + Makefile | 54 +++++++++++++++++++++++++++ 7 files changed, 160 insertions(+) create mode 100644 .flake8 create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/draft-release.yml create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/tests.yml create mode 100644 Makefile 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..dbbe3bc --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,33 @@ +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.9] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - 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/* From fc5a4b3bde8c53b9af6622572ec02c0db5cd5ec8 Mon Sep 17 00:00:00 2001 From: Patrick Quinn Date: Wed, 5 May 2021 15:24:22 -0400 Subject: [PATCH 2/4] HARMONY-833: Fix Snyk issues --- requirements-dev.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0cdff57..9fc134e 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.7.4 sphinx >= 3.2.1 sphinx-rtd-theme >= 0.5.0 -recommonmark >= 0.6.0 \ No newline at end of file +recommonmark >= 0.7.1 \ No newline at end of file From 8254122208d90d3d5100e4f3112d57610fa29bc5 Mon Sep 17 00:00:00 2001 From: Patrick Quinn Date: Wed, 5 May 2021 16:34:45 -0400 Subject: [PATCH 3/4] HARMONY-833: Update Python test version for consistency --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dbbe3bc..0c02f93 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [3.9] + python-version: [3.8] steps: - uses: actions/checkout@v2 From eac9820e3d8554059f0817b974b1e373659c89f0 Mon Sep 17 00:00:00 2001 From: Patrick Quinn Date: Wed, 5 May 2021 16:58:25 -0400 Subject: [PATCH 4/4] HARMONY-833: Add netrc with dummy user for tests --- .github/workflows/tests.yml | 6 ++++++ requirements-dev.txt | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c02f93..6e70cd3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,6 +18,12 @@ jobs: 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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 9fc134e..b7dd57b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,7 @@ pytest~=5.4 flake8~=3.8 safety >= 1.8.5 coverage >= 4.5.4 -pygments >= 2.7.4 +pygments ~= 2.9 sphinx >= 3.2.1 sphinx-rtd-theme >= 0.5.0 -recommonmark >= 0.7.1 \ No newline at end of file +recommonmark >= 0.7.1