This repository has been archived by the owner on Aug 11, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #502 from pllim/last-actions-hero
Use GitHub Actions
- Loading branch information
Showing
6 changed files
with
172 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.