Skip to content

Commit

Permalink
Merge pull request #21 from facebookresearch/samvelyan/deployment
Browse files Browse the repository at this point in the history
Added a workflow for testing and pushing the releases to PyPI
  • Loading branch information
samvelyan committed Sep 30, 2021
2 parents 0a6d980 + c2ced82 commit 69d1a54
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 4 deletions.
87 changes: 85 additions & 2 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Test & deploy
on:
push:
branches:
- master
- main
pull_request:
schedule:
- cron: "0 6,18 * * *"
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install from repo in test mode
run: "pip install -e '.[dev]'"
- name: Run tests
run: "python -m pytest minihack/tests --basetemp=minihack_test_data"
run: "python -m pytest -svx minihack/tests --basetemp=minihack_test_data"
- name: Compress test output dir
if: ${{ always() }}
run: |
Expand All @@ -60,3 +60,86 @@ jobs:
with:
name: minihack_test_data_${{ matrix.python-version }}
path: minihack_test_ci_${{ github.sha }}.tar.gz


test_sdist:
name: Test sdist on MacOS w/ Py3.8
needs: test_repo
runs-on: macos-latest
steps:
- name: Setup Python 3.8 env
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Ensure latest pip & wheel
run: "python -m pip install -q --upgrade pip wheel"
- name: Install dependencies
run: |
brew install cmake
- uses: actions/checkout@v2
with:
submodules: true
- name: Generate sdist
run: |
MINIHACK_RELEASE_BUILD=1 python setup.py sdist
- name: Install from sdist
run: |
SDISTNAME=$(ls dist/)
MODE="[all]"
pip install "dist/$SDISTNAME$MODE"
- name: Run tests outside repo dir
run: |
REPONAME=$(basename $PWD)
pushd ..
python -m pytest -svx $REPONAME/minihack/tests --basetemp=$REPONAME/minihack_test_data
popd
- name: Compress test output dir
if: ${{ always() }}
run: |
tar -zcvf minihack_test_ci_${{ github.sha }}.tar.gz minihack_test_data
- name: Save test results
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: minihack_test_data_sdist
path: minihack_test_ci_${{ github.sha }}.tar.gz
- name: Save sdist
if: ${{ always() }}
uses: actions/upload-artifact@v1
with:
name: minihack_dist
path: dist/

# TODO move this to separate workflow whenever github decides to provide basic
# functionalities like workflow dependencies :|
deploy_sdist:
name: Deploy sdist to pypi
needs: test_sdist
if: github.event_name == 'release' && github.event.action == 'released'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check version matches release tag
run: |
echo "v$(cat version.txt)"
echo "${{ github.event.release.tag_name }}"
[[ "${{ github.event.release.tag_name }}" == "v$(cat version.txt)" ]]
- name: Get dist artifacts from test_sdist
uses: actions/download-artifact@v2
with:
name: minihack_dist
path: dist
- name: Install from sdist
run: |
pwd
ls -R
ls -al .
ls -R dist/
ls -al dist/
# NOTE: we assume that dist/ contains a built sdist (and only that).
# Yes, we could be more defensively, but What Could Go Wrong?™
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include version.txt

recursive-include minihack/dat *
recursive-include minihack/lib *
recursive-include minihack/scripts *
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
long_description = f.read()
cwd = os.path.dirname(os.path.abspath(__file__))
sha = "Unknown"
version = "0.1.1"
version = open("version.txt", "r").read().strip()

try:
sha = (
Expand All @@ -100,7 +100,6 @@
print("Building wheel {}-{}".format("minihack", version))

version_path = os.path.join(cwd, "minihack", "version.py")
print(version_path)
with open(version_path, "w") as f:
f.write("__version__ = '{}'\n".format(version))
f.write("git_version = {}\n".format(repr(sha)))
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1

0 comments on commit 69d1a54

Please sign in to comment.