From 295b799a560a89494fd27bafb0a6c7fcddcbd97b Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Tue, 12 Jan 2021 17:38:20 -0500 Subject: [PATCH 1/3] Use GitHub Actions --- .github/workflows/ci_workflows.yml | 106 +++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 60 ++++++++++++++++ .travis-deploy.sh | 24 ------- .travis.yml | 46 ------------- github_deploy_key.enc | Bin 3248 -> 0 bytes 5 files changed, 166 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/ci_workflows.yml create mode 100644 .github/workflows/deploy.yml delete mode 100644 .travis-deploy.sh delete mode 100644 .travis.yml delete mode 100644 github_deploy_key.enc diff --git a/.github/workflows/ci_workflows.yml b/.github/workflows/ci_workflows.yml new file mode 100644 index 00000000..5e8fe049 --- /dev/null +++ b/.github/workflows/ci_workflows.yml @@ -0,0 +1,106 @@ +name: CI + +on: + push: + branches: + - cookiecutter + pull_request: + branches: + - cookiecutter + +# Extra context is a way to override options that the user normally +# specifies during the questions phase of the cookiecutter setup. The keys +# being overridden here must exist in the cookiecutter.json +# See https://cookiecutter.readthedocs.io/en/0.9.1/advanced_usage.html#injecting-extra-context +jobs: + tests: + name: ${{ matrix.name }} + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + include: + + - name: Default setup + extra_context: '' + extra_flags: '' + foldername: 'packagename' + + - name: Compile ext and example code + extra_context: 'use_compiled_extensions=y include_example_code=y' + extra_flags: '' + foldername: 'packagename' + + - name: Custom package name + extra_context: 'package_name=AstropyProject' + extra_flags: '' + foldername: 'AstropyProject' + + - name: Parent is sunpy + extra_context: '_parent_project=sunpy' + extra_flags: '' + foldername: 'packagename' + + - name: Python minversion + extra_context: 'minimum_python_version=3.6' + extra_flags: '' + foldername: 'packagename' + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Install Python dependencies + run: | + python -m pip install --upgrade tox + python -m pip install sphinx-astropy cookiecutter gitpython + - name: Generate package + run: | + cd docs ; make html ; cd .. + cookiecutter --no-input ./ -o ../test ${{ matrix.extra_context }} ${{ matrix.extra_flags }} + cd ../test/${{ matrix.foldername }} + git init + - name: Code style checks + run: | + cd ../test/${{ matrix.foldername }} + tox -e codestyle + - name: Build docs + run: | + cd ../test/${{ matrix.foldername }} + tox -e build_docs + - name: Tests + run: | + cd ../test/${{ matrix.foldername }} + tox -e py38-test + + # upload-artifact does not take relpath, so render inside code checkout + render: + name: Render template + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - name: Install Python dependencies + run: | + python -m pip install --upgrade tox + python -m pip install sphinx-astropy cookiecutter gitpython + - name: Generate package + run: | + cd docs ; make html ; cd .. + cookiecutter --no-input ./ -o ./test use_compiled_extensions=y include_example_code=y license=Other --config-file rendered.yml --no-input + cd ./test/packagename + git init + - name: Upload artifact + uses: actions/upload-artifact@v2 + if: github.repository == 'astropy/package-template' && github.event_name == 'push' + with: + name: rendered + path: ${{ github.workspace }}/test/packagename/ + retention-days: 1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..f77a78bb --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + upload: + name: Push template to master + runs-on: ubuntu-latest + if: github.repository == 'astropy/package-template' && github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' + steps: + - name: Set up Git + run: | + git --version + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Download artifact + uses: actions/github-script@v3 + with: + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "rendered" + })[0]; + var download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{ github.workspace }}/rendered.zip', Buffer.from(download.data)); + - name: Unzip artifact + run: | + mkdir -p test/packagename + mv rendered.zip test/packagename + cd test/packagename + unzip rendered.zip + rm rendered.zip + - name: Checkout code + uses: actions/checkout@v2 + with: + path: 'test/rendered_dir' + token: ${{ secrets.ACTIONS_TOKEN }} + - name: Run script + run: | + cd ${{ github.workspace }}/test/rendered_dir + git remote update + git checkout master + rsync -avz --delete --exclude .git/ ../packagename/ ./ + git add -A + git commit --allow-empty -m "Update rendered version to ""$GITHUB_SHA" + git push origin master diff --git a/.travis-deploy.sh b/.travis-deploy.sh deleted file mode 100644 index 152b432a..00000000 --- a/.travis-deploy.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -set -evax - -if [[ "${TRAVIS_PULL_REQUEST}" = "false" && "$TRAVIS_OS_NAME" = "linux" && $TASK = 'render' ]]; then - openssl aes-256-cbc -K $encrypted_c554857c6215_key -iv $encrypted_c554857c6215_iv -in github_deploy_key.enc -out ~/.ssh/publish-key -d - chmod u=rw,og= ~/.ssh/publish-key - echo "Host github.com" >> ~/.ssh/config - echo " IdentityFile ~/.ssh/publish-key" >> ~/.ssh/config - - base_dir=$(pwd) - - cd ../test/ - git clone git@github.com:astropy/package-template rendered - cd rendered - git --version - git config --global user.name "Travis CI" - git config --global user.email "travis@travis.ci" - git remote update - git checkout master - rsync -avz --delete --exclude .git/ ../packagename/ ./ - git add -A - git commit --allow-empty -m "Update rendered version to ""$TRAVIS_COMMIT" - git push origin master -fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 299bcccd..00000000 --- a/.travis.yml +++ /dev/null @@ -1,46 +0,0 @@ -language: python - -os: - - linux - -python: 3.8 - -env: - global: - - # The following versions are the 'default' for tests, unless - # overridden underneath. They are defined here in order to save having - # to repeat them for all configurations. - - FOLDERNAME='packagename' - - TASK='test' - - EXTRA_CONTEXT='' - - FLAGS='' - - matrix: - # Extra context is a way to override options that the user normally - # specifies during the questions phase of the cookiecutter setup. The keys - # being overridden here must exist in the cookiecutter.json - # See https://cookiecutter.readthedocs.io/en/0.9.1/advanced_usage.html#injecting-extra-context - - EXTRA_CONTEXT='' - - EXTRA_CONTEXT='use_compiled_extensions=y include_example_code=y' - - EXTRA_CONTEXT="package_name=AstropyProject" FOLDERNAME='AstropyProject' - - EXTRA_CONTEXT='_parent_project=sunpy' - - EXTRA_CONTEXT='minimum_python_version=3.6' - - TASK='render' FLAGS='--config-file rendered.yml --no-input' EXTRA_CONTEXT='use_compiled_extensions=y include_example_code=y license=Other' - -install: - - pip install sphinx-astropy cookiecutter gitpython tox - -script: - - cd docs ; make html ; cd .. - - cookiecutter --no-input ./ -o ../test $EXTRA_CONTEXT $FLAGS - - cd ../test/$FOLDERNAME - - git init - - if [[ $TASK == 'test' ]]; then tox -e py38-test; fi - - if [[ $TASK == 'test' ]]; then tox -e build_docs; fi - - if [[ $TASK == 'test' ]]; then tox -e codestyle; fi - - -after_success: - - cd ../../package-template - - bash .travis-deploy.sh diff --git a/github_deploy_key.enc b/github_deploy_key.enc deleted file mode 100644 index 7ff1d279d6adf2b6f5a165843acd9460b8f494cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3248 zcmV;h3{UehFfRa!n4rc{+Hoe0H9H`5+NR<+;DglVt?!`t>u?Dc*Gf@$<{tf$z;8zT zv{t|T8akrAB{H{yTY4qSS>@;e4k6AAGdtPi(39;?s;oUnt>=SN6*+bSwiL!n692cH7MYx{Xjydk`bb)^2>59gUIW4ouhg%z~N+;eWSAqa=jhQAgxp-|O6XFP*Hlzm;irBru z{91q*VY`hXDurgY+Q%9IErQm~i7`k_X-0{2o3OXdm5UYl7f)*zPGti!#gCDo-R00? zcO`0fVe0*;IidQT$kRv&cXw{SonKocYmL;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 -0500 Subject: [PATCH 2/3] DOC: Update README badges --- README.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 569a0f30..b0b27c0c 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Astropy package template ======================== -|powered| - **cookiecutter branch:** |travis cookiecutter| - **master branch:** |travis master| +|powered| - **cookiecutter branch:** |ci cookiecutter| This is a package template provided by the Astropy project. @@ -67,10 +67,6 @@ For further information on writing templates for cookiecutter see `the cookiecut :target: http://www.astropy.org :alt: Powered by Astropy Badge -.. |travis cookiecutter| image:: https://travis-ci.org/astropy/package-template.svg?branch=cookiecutter - :target: https://travis-ci.org/astropy/package-template - :alt: Travis cookiecutter badge - -.. |travis master| image:: https://travis-ci.org/astropy/package-template.svg?branch=master - :target: https://travis-ci.org/astropy/package-template - :alt: Travis master badge +.. |ci cookiecutter| image:: https://github.com/astropy/package-template/workflows/CI/badge.svg + :target: https://github.com/astropy/package-template/actions + :alt: CI cookiecutter badge From bd97eba5d35685604a16567829eac8bec4954f54 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Tue, 26 Jan 2021 09:53:20 -0500 Subject: [PATCH 3/3] Add a note about download artifact script [ci skip] --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f77a78bb..54b6708a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -6,6 +6,8 @@ on: types: - completed +# github-script can be replaced then this issue is fixed: +# https://github.com/actions/download-artifact/issues/60 jobs: upload: name: Push template to master