diff --git a/.github/workflows/update_sdk.yml b/.github/workflows/update_sdk.yml index 3671514..fa898c6 100644 --- a/.github/workflows/update_sdk.yml +++ b/.github/workflows/update_sdk.yml @@ -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] }} @@ -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 \ No newline at end of file diff --git a/generate.sh b/generate.sh index 77aa2ff..4236a72 100755 --- a/generate.sh +++ b/generate.sh @@ -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) \ @@ -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) \ @@ -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) \ @@ -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) \ diff --git a/python_sdk_templates/github_actions.mustache b/python_sdk_templates/github_actions.mustache new file mode 100644 index 0000000..04bbf98 --- /dev/null +++ b/python_sdk_templates/github_actions.mustache @@ -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}}}