Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release flow #199

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ on:
branches:
- master
paths-ignore:
- .readthedocs.yaml
- '**.md'
pull_request:
branches:
- master
paths-ignore:
- .readthedocs.yaml
- '**.md'
- doc/*
jobs:
test:
name: Test
Expand All @@ -24,8 +19,8 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
# - '3.10' 3.10+ require moving off of nose (https://github.com/nose-devs/nose/issues/1099)
# - '3.11'
- '3.10'
- '3.11'
steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -38,6 +33,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Extract version
id: extract-version
run: |
PACKAGE_VERSION="$(./scripts/version.sh)"
echo "version=$PACKAGE_VERSION" >>"$GITHUB_OUTPUT"
- name: Download Hadoop
run: |
echo "HADOOP_HOME=$(./scripts/hadoop.sh download)" >>"$GITHUB_ENV"
Expand All @@ -56,6 +56,22 @@ jobs:
run: HDFSCLI_TEST_URL="$WEBHDFS_URL" python -m pytest --cov=hdfs
- name: Test on HTTPFS
run: HDFSCLI_TEST_URL="$HTTPFS_URL" HDFSCLI_NOSNAPSHOT=1 python -m pytest --cov=hdfs
- name: Check if tag exists
uses: mukunku/[email protected]
id: check-version
with:
tag: v${{ steps.extract-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
if: steps.check-version.outputs.exists == 'false'
uses: pkgdeps/git-tag-action@v2
with:
git_commit_sha: ${{ github.sha }}
git_tag_prefix: v
github_repo: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ steps.extract-version.outputs.version }}
- name: Stop HDFS
if: always()
run: ./scripts/hadoop.sh stop
55 changes: 55 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: PR
on:
pull_request:
branches:
- master
paths-ignore:
- '**.md'
- .readthedocs.yaml
- doc/*
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
# - '3.6' (see https://github.com/actions/setup-python/issues/544)
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: Check out
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download Hadoop
run: |
echo "HADOOP_HOME=$(./scripts/hadoop.sh download)" >>"$GITHUB_ENV"
- name: Configure Hadoop
run: |
echo "HADOOP_CONF_DIR=$(./scripts/hadoop.sh config)" >>"$GITHUB_ENV"
- name: Start HDFS
run: |
./scripts/hadoop.sh start
echo "WEBHDFS_URL=http://$("$HADOOP_HOME/bin/hdfs" getconf -confKey dfs.namenode.http-address)" >>"$GITHUB_ENV"
echo "HTTPFS_URL=http://localhost:14000" >>"$GITHUB_ENV"
sleep 5 # TODO: Find a better way to wait for all datanodes to become reachable.
- name: Install
run: pip install .[avro] coverage mock pytest pytest-cov pandas
- name: Test on WebHDFS
run: HDFSCLI_TEST_URL="$WEBHDFS_URL" python -m pytest --cov=hdfs
- name: Test on HTTPFS
run: HDFSCLI_TEST_URL="$HTTPFS_URL" HDFSCLI_NOSNAPSHOT=1 python -m pytest --cov=hdfs
- name: Stop HDFS
if: always()
run: ./scripts/hadoop.sh stop
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release
on:
release:
types:
- published
jobs:
test:
name: Publish
timeout-minutes: 2
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Publish
run: |
python setup.py sdist
twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
25 changes: 25 additions & 0 deletions scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail
shopt -s nullglob

__dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

fail() { # MSG
echo "$1" >&2 && exit 1
}

version_pattern="__version__ = '([^']+)'"

main() {
cd "$__dirname/.."
local line="$(grep __version__ hdfs/__init__.py)"
if ! [[ $line =~ $version_pattern ]]; then
fail 'missing version'
fi
echo "${BASH_REMATCH[1]}"
}

main "$@"