Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #502 from pllim/last-actions-hero
Browse files Browse the repository at this point in the history
Use GitHub Actions
  • Loading branch information
pllim committed Feb 5, 2021
2 parents 589d874 + bd97eba commit 6dbb3f5
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 78 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 0 additions & 24 deletions .travis-deploy.sh

This file was deleted.

46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

12 changes: 4 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Binary file removed github_deploy_key.enc
Binary file not shown.

0 comments on commit 6dbb3f5

Please sign in to comment.