Skip to content

Commit

Permalink
init pytest as action
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed Feb 2, 2022
1 parent 5bd6f94 commit d3bd495
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
jobs:
test-check:
name: runner / <linter-name> (github-check)
name: runner / pytest (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -19,7 +19,7 @@ jobs:

test-pr-check:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-check)
name: runner / pytest (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -33,7 +33,7 @@ jobs:

test-pr-review:
if: github.event_name == 'pull_request'
name: runner / <linter-name> (github-pr-review)
name: runner / pytest (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM alpine:3.15
FROM python:alpine

ENV REVIEWDOG_VERSION=v0.13.0

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

# hadolint ignore=DL3006
RUN apk --no-cache add git
# hadolint ignore=DL3006,DL3018
RUN apk --no-cache add git graphviz

RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}

# TODO: Install a linter and/or change docker image as you need.
# hadolint ignore=DL3013
RUN python -m pip install --no-cache-dir --upgrade pytest pytest-cov pytest-profiling pytest-timeout

RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/

COPY entrypoint.sh /entrypoint.sh
Expand Down
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'TODO: Run <linter-name> with reviewdog'
description: 'TODO: 🐶 Run <linter-name> with reviewdog on pull requests to improve code review experience.'
author: 'TODO: <your-name>'
name: 'Run pytest with reviewdog'
description: '🐶 Run pytest with reviewdog on pull requests to improve code review experience.'
author: 'Ross Chadwick'
inputs:
github_token:
description: 'GITHUB_TOKEN'
Expand Down Expand Up @@ -28,7 +28,7 @@ inputs:
reviewdog_flags:
description: 'Additional reviewdog flags'
default: ''
### Flags for <linter-name> ###
### Flags for pytest ###
locale:
description: '-locale flag of misspell. (US/UK)'
default: ''
Expand Down
21 changes: 12 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/bin/sh
set -e

if [ -n "${GITHUB_WORKSPACE}" ] ; then
if [ -n "${GITHUB_WORKSPACE}" ]; then
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
fi

export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

misspell -locale="${INPUT_LOCALE}" . \
| reviewdog -efm="%f:%l:%c: %m" \
-name="linter-name (misspell)" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
misspell -locale="${INPUT_LOCALE}" . |
reviewdog -efm="%f:%l:%c: %m" \
-name="pytest (misspell)" \
-reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
"${INPUT_REVIEWDOG_FLAGS}"

echo "[action-pytest] Running pytest on \"${INPUT_WORKDIR}\"..."
pytest --profile-svg --cov="${INPUT_WORKDIR}" "${INPUT_WORKDIR}"

0 comments on commit d3bd495

Please sign in to comment.