Skip to content

Commit

Permalink
Merge pull request #3 from neurostuff/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
jdkent authored Apr 2, 2022
2 parents 1c0cfad + 9982fe4 commit ae93955
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/update_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ jobs:
with:
repository: neurostuff/${{ matrix.sdk[0] }}
path: ${{ matrix.sdk[1] }}/${{ matrix.sdk[0] }}
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 45
- name: Checkout reciprical branch
run: |
cd ${{ matrix.sdk[1] }}/${{ matrix.sdk[0] }}
git checkout ${{ github.base_ref }} 2>/dev/null || git checkout -b ${{ github.base_ref }}
git fetch
git ls-remote --exit-code --heads origin ${{ github.ref_name }} || git branch ${{ github.ref_name }}
git checkout ${{ github.ref_name }}
- name: Generate SDK
run: |
./generate.sh ${{ matrix.sdk[0] }}
Expand All @@ -33,11 +38,16 @@ jobs:
cd ${{ matrix.sdk[1] }}/${{ matrix.sdk[0] }}
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# check to see if there were any changes to the repository.
git config --local --unset-all "http.https://github.com/.extraheader"
# check to see if there were any changes to the repository and no branches made
if [ -z $(git ls-files --other --exclude-standard --directory) ]; then
echo "No files to be committed!"
if [ -z $(git ls-remote --heads origin ${{ github.ref_name }}) ]; then
git push -q https://${{ secrets.SDK_PAT }}@github.com/neurostuff/${{ matrix.sdk[0] }}.git ${{ github.ref_name }}
else
echo "branch already exists and is up to date"
fi
else
git commit -m "${{ github.sha }}" -a
git push -q https://${{ secrets.SDK_PAT }}@github.com/neurostuff/${{ matrix.sdk[0] }}.git ${{ github.base_ref }}
git push -q https://${{ secrets.SDK_PAT }}@github.com/neurostuff/${{ matrix.sdk[0] }}.git ${{ github.ref_name }}
fi
8 changes: 4 additions & 4 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

generate=$1

if [ -z ${generate} ] || [ ${generate} == "python-neurostore" || [ ${generate} == "neurostore-python-sdk" ]; then
if [ -z ${generate} ] || [ ${generate} == "python-neurostore" ] || [ ${generate} == "neurostore-python-sdk" ]; then

echo "generating python-neurostore-sdk..."
docker run --rm --user $(id -u):$(id -g) \
Expand All @@ -13,7 +13,7 @@ if [ -z ${generate} ] || [ ${generate} == "python-neurostore" || [ ${generate} =
-o /local/python/neurostore-sdk
fi

if [ -z ${generate} ] || [ ${generate} == "typescript-neurostore" ] || [ ${generate} == "neurostore-typescript-sdk "]; then
if [ -z ${generate} ] || [ ${generate} == "typescript-neurostore" ] || [ ${generate} == "neurostore-typescript-sdk" ]; then

echo "generating typescript-neurostore-sdk..."
docker run --rm --user $(id -u):$(id -g) \
Expand All @@ -23,7 +23,7 @@ if [ -z ${generate} ] || [ ${generate} == "typescript-neurostore" ] || [ ${gener
-o /local/typescript/neurostore-sdk
fi

if [ -z ${generate} ] || [ ${generate} == "python-neurosynth-compose" ] || [ ${generate} == "neurosynth-compose-python-sdk "]; then
if [ -z ${generate} ] || [ ${generate} == "python-neurosynth-compose" ] || [ ${generate} == "neurosynth-compose-python-sdk" ]; then

echo "generating python-neurosynth-compose-sdk..."
docker run --rm --user $(id -u):$(id -g) \
Expand All @@ -34,7 +34,7 @@ if [ -z ${generate} ] || [ ${generate} == "python-neurosynth-compose" ] || [ ${g
-o /local/python/neurosynth-compose-sdk
fi

if [ -z ${generate} ] || [ ${generate} == "typescript-neurosynth-compose" ] || [ ${generate} == "neurosynth-compose-typescript-sdk "]; then
if [ -z ${generate} ] || [ ${generate} == "typescript-neurosynth-compose" ] || [ ${generate} == "neurosynth-compose-typescript-sdk" ]; then

echo "generating typescript-neurosynth-compose-sdk..."
docker run --rm --user $(id -u):$(id -g) \
Expand Down
23 changes: 23 additions & 0 deletions python_sdk_templates/github_actions.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test {{{packageName}}}
on: [push, pull_request]
jobs:
pytest:
runs-on: {{=<% %>=}}${{ matrix.os }}<%={{ }}=%>
strategy:
matrix:
os: [ubuntu-20.04]
python: ["3.6", "3.7", "3.8", "3.9", "3.10"]
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Install python {{=<% %>=}}${{ matrix.python }}<%={{ }}=%>
uses: actions/setup-python@v3
with:
python-version: {{=<% %>=}}${{ matrix.python }}<%={{ }}=%>
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r test-requirements.txt
- name: Run pytest
run: |
pytest --cov={{{packageName}}}

0 comments on commit ae93955

Please sign in to comment.