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
64 changes: 7 additions & 57 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,14 @@
name: Coverage

on:
pull_request:
push:
workflow_dispatch:

jobs:
# copied from test.yml
changes:
name: Check if back-end or front-end files changed
# Don't run this for pushes generated by push.yml on weblate-localization
# branch → prevents an infinite loop of actions triggering actions
#
# Also, "push" event is not triggered for forks, so need to listen for
# pull_requests, but only for external ones, so as not to run the action
# twice
if: |
(github.event_name == 'workflow_dispatch' ||
(github.event.head_commit.committer.name != 'Hosted Weblate' &&
github.event.head_commit.committer.name != 'github-actions'))
&&
(
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.fork == true
)
runs-on: ubuntu-latest
outputs:
backend_changed: ${{ steps.back-end-check.outputs.changed }}
frontend: ${{ steps.filter.outputs.frontend }}
frontend_changes: ${{ steps.filter.outputs.frontend_files }}

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Find all changed files
uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ github.ref }}
list-files: escape
filters: |
frontend:
- 'specifyweb/frontend/**'
backend:
- '**'

- name: Check if any non-front-end files changed
id: back-end-check
run: |
changed_files=`echo "${{steps.filter.outputs.backend_files}}" | tr " " "\n" | grep -v 'specifyweb/frontend/' || echo ""`
echo "Changed back-end files: ${changed_files}"
echo "changed=$([[ -z "${changed_files}" ]] && echo "" || echo "1")" >> $GITHUB_OUTPUT

setup-and-run:
needs: changes
if: |
(needs.changes.outputs.backend_changed ||
needs.changes.outputs.frontend) ||
github.event_name == 'workflow_dispatch'
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Install needed packages
Expand All @@ -87,7 +34,7 @@ jobs:
- name: Configure specify
id: config-specify
run: |
cat > .env <<-EOS
{ IFS= read -d "" -r env <<-EOS
DATABASE_HOST=mariadb
DATABASE_PORT=3306
MYSQL_ROOT_PASSWORD=password
Expand Down Expand Up @@ -128,6 +75,9 @@ jobs:

SP7_DEBUG=true
EOS
} || true

echo "$env" > .env

sed -i 's/#[ ]*\(.*requirements-testing.txt\)/\1/; s/\(COPY\) \(requirements-testing.txt\)/\1 --chown=specify:specify \2/' Dockerfile
sed -i 's/\(\(DATABASE_\|MASTER_\|MIGRATOR\|APP_USER_\)[^O].*\) = \(.*\)/\1 = os.environ.get("\1", "")/' specifyweb/settings/specify_settings.py
Expand Down
9 changes: 8 additions & 1 deletion specifyweb/frontend/js_src/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ const config = {
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,
collectCoverageFrom: [
'**/*.{js,jsx,ts,tsx}',
'!**/*tests*/**',
'!**/*test*',
'!**/localization/**',
'!**/*Route*/**',
'!**/*Route*',
],
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',
Expand Down
Loading