Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an action for check-links #97

Merged
merged 1 commit into from
Aug 3, 2021
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
31 changes: 31 additions & 0 deletions .github/actions/check-links/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Check Links"
description: "Run a link check function for a repo"
runs:
using: "composite"
steps:
- shell: bash
id: check-links
run: |
set -eux

# Set up env variables
export RH_REPOSITORY=${GITHUB_REPOSITORY}
export RH_REF=${GITHUB_REF}

if [ ! -z ${GITHUB_BASE_REF} ]; then
echo "Using GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
export RH_BRANCH=${GITHUB_BASE_REF}
else
# e.g refs/head/foo or refs/tag/bar
echo "Using GITHUB_REF: ${GITHUB_REF}"
export RH_BRANCH=$(echo ${GITHUB_REF} | cut -d'/' -f 3-)
fi

# Install Jupyter Releaser from git unless we are testing Releaser itself
if ! command -v jupyter-releaser &> /dev/null
then
pip install git+https://github.com/jupyter-server/jupyter_releaser.git
fi

jupyter-releaser prep-git
jupyter-releaser check-links --force
7 changes: 0 additions & 7 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-pip-
- name: Cache checked links
uses: actions/cache@v2
with:
path: ~/.cache/pytest-link-check
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/*.md') }}-md-links
restore-keys: |
${{ runner.os }}-linkcheck-
- name: Print env
run: env
- name: Upgrade packaging dependencies
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,42 @@ jobs:
echo "or after-the-fact on already committed files with"
echo " pre-commit run --all-files"

check-links:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Install the Python dependencies
run: |
pip install -e .[test] codecov
- name: Cache checked links
uses: actions/cache@v2
with:
path: ~/.cache/pytest-link-check
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/*.md') }}-md-links
restore-keys: |
${{ runner.os }}-linkcheck-
- name: Install the Python dependencies
run: |
pip install -e .[test] codecov
- name: Check Links
uses: ./.github/actions/check-links

build:
runs-on: ${{ matrix.os }}-latest
strategy:
Expand Down
8 changes: 7 additions & 1 deletion jupyter_releaser/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def invoke(self, ctx):
hooks = config.get("hooks", {})
options = config.get("options", {})
skip = config.get("skip", [])
if "--force" in ctx.args:
skip = []
ctx.args.remove("--force")

# Print a separation header
util.log(f'\n\n{"-" * 50}')
Expand Down Expand Up @@ -119,7 +122,10 @@ def list_commands(self, ctx):


@click.group(cls=ReleaseHelperGroup)
def main():
@click.option(
"--force", default=False, help="Force a command to run even when skipped by config"
)
def main(force):
"""Jupyter Releaser scripts"""
pass

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ tag_template = "v{new_version}"
[[tool.tbump.file]]
src = "jupyter_releaser/__init__.py"

[tool.jupyter-releaser]
skip = ["check-links"]

[tool.jupyter-releaser.hooks]
after-draft-release = "bash ./.github/scripts/bump_tag.sh"