Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CFPB GitHub Actions workflow templates

This repo houses CFPB-specific GitHub Actions workflow templates.

To use our workflow templates, click on the "Actions" tab in a CFPB GitHub repository. If the repository does not already have a GitHub Actions workflow, you will be presented with the option of creating one from one of our templates:

![GitHub Actions template listing](github-actions-templates.png)

If the repository already has a GitHub Actions workflow, click on the "New workflow" button at the top of the workflow list on the left.

![GitHub Actions New workflow button](github-actions-new-workflow.png)

Then you will be presented with the option to create one from one of our templates, shown above.

New workflow templates can be created in [github.com/cfpb/.github](https://github.com/cfpb/.github) based on [GitHub's workflow template documentation](https://docs.github.com/en/actions/configuring-and-managing-workflows/sharing-workflow-templates-within-your-organization).

## consumerfinance.gov-specific workflow templates

- [cfgov-frontend-ci.yml](workflow-templates/cfgov-frontend-ci.yml): A frontend CI workflow template for cf.gov satellite apps.
- [cfgov-python-satellite-ci.yml](workflow-templates/cfgov-python-satellite-ci.yml): A backend CI workflow template for cf.gov satellite apps based on tox.
Comment on lines +17 to +20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about reframing these as general front-end/back-end CI workflows? They offer what we would consider to be best practices for any CFPB project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that...it felt somewhat presumptuous to me to do that (at least on the backend because it presupposes Python).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can word it in such a way that it doesn't. Maybe instead of calling them frontend/backend, it should be JavaScript/Python?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Scotchester looking at this again, I'm fine moving cfgov-frontend-ci to cfpb-javascript-ci, but I think I'd like to keep the distinction between cfgov satellites and Python libraries, even if the only difference is the default of including Django in the tox matrix.

- [cfgov-python-satellite-release.yml](workflow-templates/cfgov-python-satellite-release.yml): A workflow template for cf.gov satellite apps that attaches a Python wheel file to a GitHub release when the release is published.

## General-purpose library workflow templates

- [cfpb-pypi-publish.yml](workflow-templates/cfpb-pypi-publish.yml): A workflow to publish Python packages to PyPI when a GitHub release is published.
- [cfpb-python-library-ci.yml](workflow-templates/cfpb-python-library-ci.yml): A Python CI workflow template for CFPB Python libraries based on tox.

## Miscellaneous workflow templates

- [cfpb-mkdocs-publish.yml](workflow-templates/cfpb-mkdocs-publish.yml): A workflow template to publish MkDocs documentation to gh-pages on merges to main.
Binary file added github-actions-new-workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added github-actions-templates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions workflow-templates/blank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions workflow-templates/cfgov-python-satellite-ci.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "cf.gov satellite app backend CI workflow",
"description": "A backend CI workflow template for cf.gov satellite apps based on tox.",
"iconName": "django",
"categories": [
"Python"
],
"filePatterns": [
"^setup.py$",
"^tox.ini$"
]
}
40 changes: 40 additions & 0 deletions workflow-templates/cfgov-python-satellite-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Python CI workflow

on: [pull_request, push]

jobs:
backend:
runs-on: ubuntu-latest

strategy:
matrix:
# Add the appropriate Tox environments for the satellite here
toxenv:
- py36
- py38
include:
# Adjust the Python versions required for the tox environments as
# needed
- toxenv: py36-dj22
python-version: 3.6
- toxenv: py38-dj22
python-version: 3.8

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Run back-end tests
run: |
tox
env:
TOXENV: ${{ matrix.toxenv }}
11 changes: 11 additions & 0 deletions workflow-templates/cfgov-python-satellite-release.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "cf.gov satellite app release workflow",
"description": "A release workflow template for cf.gov satellite apps.",
"iconName": "django",
"categories": [
"Python"
],
"filePatterns": [
"setup.py$"
]
}
63 changes: 63 additions & 0 deletions workflow-templates/cfgov-python-satellite-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Our consumerfinance.gov satellite apps publish wheel files to GitHub
# when released. This is an example workflow to perform that task.
name: Publish wheel file

on:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

# If the package has a front-end build we need to set up and install
# Node and other dependencies
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 10.x

- name: Install Node dependencies
run: |
npm install -g gulp-cli
npm config set package-lock false

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.6

- name: Install Python dependencies
run: python -m pip install --upgrade pip wheel

- name: Build the packages
id: build
run: |
python setup.py sdist bdist_wheel
# Get the name of the .whl and .tar.gz files and set them as
# "outputs" of this step so we can upload them
echo "::set-output name=bdist_wheel::$(cd dist && ls *.whl)"
echo "::set-output name=sdist::$(cd dist && ls *.tar.gz)"

- name: Upload the wheel
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/${{ steps.build.outputs.bdist_wheel }}
asset_name: ${{ steps.build.outputs.bdist_wheel }}
asset_content_type: application/zip

- name: Upload the source distribution
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/${{ steps.build.outputs.sdist }}
asset_name: ${{ steps.build.outputs.sdist }}
asset_content_type: application/gzip

11 changes: 11 additions & 0 deletions workflow-templates/cfpb-javascript-ci.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "CFPB JavaScript CI workflow",
"description": "A Javascript CI workflow template for CFPB repositories based on Gulp.",
"iconName": "nodejs",
"categories": [
"JavaScript"
],
"filePatterns": [
"package.json$"
]
}
28 changes: 28 additions & 0 deletions workflow-templates/cfpb-javascript-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Frontend CI workflow

on: [pull_request, push]

jobs:

frontend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Install Node dependencies
run: |
npm config set package-lock false
npm install

- name: Lint front-end code
run: gulp lint

- name: Run front-end unit tests
run: npm test

8 changes: 8 additions & 0 deletions workflow-templates/cfpb-mkdocs-publish.properies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "CFPB MkDocs publish workflow",
"description": "A workflow template to publish MkDocs documentation to gh-pages on merges to main.",
"iconName": "blank",
"filePatterns": [
"^mkdocs.yml$"
]
}
30 changes: 30 additions & 0 deletions workflow-templates/cfpb-mkdocs-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
push:
branches:
- $default-branch

jobs:

publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: |
git fetch --no-tags --prune --depth=1 origin gh-pages

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.6

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r mkdocs

- name: Build docs
run: mkdocs build

- name: Publish docs
run: mkdocs gh-deploy
11 changes: 11 additions & 0 deletions workflow-templates/cfpb-pypi-publish.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "CFPB PyPI publish workflow",
"description": "A workflow to publish Python packages to PyPI when a GitHub release is published.",
"iconName": "python",
"categories": [
"Python"
],
"filePatterns": [
"^setup.py$"
]
}
36 changes: 36 additions & 0 deletions workflow-templates/cfpb-pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Some of our libraries get published to PyPI
# (https://github.com/cfpb/development/blob/master/guides/pypi.md)
#
# This workflow requires `TWINE_USERNAME` and `TWINE_PASSWORD` set in the
# repository as secrets.
name: Publish to PyPI
on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v1

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel

- name: Build the package
run: |
python setup.py sdist bdist_wheel --universal

- name: Upload to PyPI
run: twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
12 changes: 12 additions & 0 deletions workflow-templates/cfpb-python-library-ci.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "CFPB Python library CI workflow",
"description": "A Python CI workflow template for CFPB Python libraries based on tox.",
"iconName": "python",
"categories": [
"Python"
],
"filePatterns": [
"^setup.py$",
"^tox.ini$"
]
}
40 changes: 40 additions & 0 deletions workflow-templates/cfpb-python-library-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Python CI workflow

on: [pull_request, push]

jobs:
backend:
runs-on: ubuntu-latest

strategy:
matrix:
# Add the appropriate Tox environments for the satellite here
toxenv:
- py36
- py38
include:
# Adjust the Python versions required for the tox environments as
# needed
- toxenv: py36
python-version: 3.6
- toxenv: py38
python-version: 3.8

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Run back-end tests
run: |
tox
env:
TOXENV: ${{ matrix.toxenv }}
1 change: 1 addition & 0 deletions workflow-templates/django.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions workflow-templates/nodejs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions workflow-templates/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.