diff --git a/.github/actions/check-links/action.yml b/.github/actions/check-links/action.yml new file mode 100644 index 00000000..05c6582e --- /dev/null +++ b/.github/actions/check-links/action.yml @@ -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 diff --git a/.github/workflows/check-release.yml b/.github/workflows/check-release.yml index 3a221cdf..82c9f8ee 100644 --- a/.github/workflows/check-release.yml +++ b/.github/workflows/check-release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0bb8310b..495e8e9b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: diff --git a/jupyter_releaser/cli.py b/jupyter_releaser/cli.py index dcad7010..9f9ab02b 100644 --- a/jupyter_releaser/cli.py +++ b/jupyter_releaser/cli.py @@ -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}') @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 92df9183..3667f598 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"