Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 69d1a54

Browse files
authored
Merge pull request #21 from facebookresearch/samvelyan/deployment
Added a workflow for testing and pushing the releases to PyPI
2 parents 0a6d980 + c2ced82 commit 69d1a54

File tree

4 files changed

+89
-4
lines changed

4 files changed

+89
-4
lines changed

.github/workflows/test_and_deploy.yml

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Test & deploy
44
on:
55
push:
66
branches:
7-
- master
7+
- main
88
pull_request:
99
schedule:
1010
- cron: "0 6,18 * * *"
@@ -49,7 +49,7 @@ jobs:
4949
- name: Install from repo in test mode
5050
run: "pip install -e '.[dev]'"
5151
- name: Run tests
52-
run: "python -m pytest minihack/tests --basetemp=minihack_test_data"
52+
run: "python -m pytest -svx minihack/tests --basetemp=minihack_test_data"
5353
- name: Compress test output dir
5454
if: ${{ always() }}
5555
run: |
@@ -60,3 +60,86 @@ jobs:
6060
with:
6161
name: minihack_test_data_${{ matrix.python-version }}
6262
path: minihack_test_ci_${{ github.sha }}.tar.gz
63+
64+
65+
test_sdist:
66+
name: Test sdist on MacOS w/ Py3.8
67+
needs: test_repo
68+
runs-on: macos-latest
69+
steps:
70+
- name: Setup Python 3.8 env
71+
uses: actions/setup-python@v2
72+
with:
73+
python-version: 3.8
74+
- name: Ensure latest pip & wheel
75+
run: "python -m pip install -q --upgrade pip wheel"
76+
- name: Install dependencies
77+
run: |
78+
brew install cmake
79+
- uses: actions/checkout@v2
80+
with:
81+
submodules: true
82+
- name: Generate sdist
83+
run: |
84+
MINIHACK_RELEASE_BUILD=1 python setup.py sdist
85+
- name: Install from sdist
86+
run: |
87+
SDISTNAME=$(ls dist/)
88+
MODE="[all]"
89+
pip install "dist/$SDISTNAME$MODE"
90+
- name: Run tests outside repo dir
91+
run: |
92+
REPONAME=$(basename $PWD)
93+
pushd ..
94+
python -m pytest -svx $REPONAME/minihack/tests --basetemp=$REPONAME/minihack_test_data
95+
popd
96+
- name: Compress test output dir
97+
if: ${{ always() }}
98+
run: |
99+
tar -zcvf minihack_test_ci_${{ github.sha }}.tar.gz minihack_test_data
100+
- name: Save test results
101+
if: ${{ always() }}
102+
uses: actions/upload-artifact@v1
103+
with:
104+
name: minihack_test_data_sdist
105+
path: minihack_test_ci_${{ github.sha }}.tar.gz
106+
- name: Save sdist
107+
if: ${{ always() }}
108+
uses: actions/upload-artifact@v1
109+
with:
110+
name: minihack_dist
111+
path: dist/
112+
113+
# TODO move this to separate workflow whenever github decides to provide basic
114+
# functionalities like workflow dependencies :|
115+
deploy_sdist:
116+
name: Deploy sdist to pypi
117+
needs: test_sdist
118+
if: github.event_name == 'release' && github.event.action == 'released'
119+
runs-on: ubuntu-latest
120+
steps:
121+
- uses: actions/checkout@v2
122+
- name: Check version matches release tag
123+
run: |
124+
echo "v$(cat version.txt)"
125+
echo "${{ github.event.release.tag_name }}"
126+
[[ "${{ github.event.release.tag_name }}" == "v$(cat version.txt)" ]]
127+
- name: Get dist artifacts from test_sdist
128+
uses: actions/download-artifact@v2
129+
with:
130+
name: minihack_dist
131+
path: dist
132+
- name: Install from sdist
133+
run: |
134+
pwd
135+
ls -R
136+
ls -al .
137+
ls -R dist/
138+
ls -al dist/
139+
# NOTE: we assume that dist/ contains a built sdist (and only that).
140+
# Yes, we could be more defensively, but What Could Go Wrong?™
141+
- name: Publish package to PyPI
142+
uses: pypa/gh-action-pypi-publish@master
143+
with:
144+
user: __token__
145+
password: ${{ secrets.PYPI_TOKEN }}

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include version.txt
2+
13
recursive-include minihack/dat *
24
recursive-include minihack/lib *
35
recursive-include minihack/scripts *

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
long_description = f.read()
8585
cwd = os.path.dirname(os.path.abspath(__file__))
8686
sha = "Unknown"
87-
version = "0.1.1"
87+
version = open("version.txt", "r").read().strip()
8888

8989
try:
9090
sha = (
@@ -100,7 +100,6 @@
100100
print("Building wheel {}-{}".format("minihack", version))
101101

102102
version_path = os.path.join(cwd, "minihack", "version.py")
103-
print(version_path)
104103
with open(version_path, "w") as f:
105104
f.write("__version__ = '{}'\n".format(version))
106105
f.write("git_version = {}\n".format(repr(sha)))

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.1

0 commit comments

Comments
 (0)