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..54b6708a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,62 @@ +name: Deploy + +on: + workflow_run: + workflows: ["CI"] + 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 + 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/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 diff --git a/github_deploy_key.enc b/github_deploy_key.enc deleted file mode 100644 index 7ff1d279..00000000 Binary files a/github_deploy_key.enc and /dev/null differ