diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7b358ba6250..743e0f4ef0f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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 @@ -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 @@ -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 diff --git a/specifyweb/frontend/js_src/jest.config.cjs b/specifyweb/frontend/js_src/jest.config.cjs index 9c4ac108614..eb33b235af8 100644 --- a/specifyweb/frontend/js_src/jest.config.cjs +++ b/specifyweb/frontend/js_src/jest.config.cjs @@ -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*', + ], // The directory where Jest should output its coverage files coverageDirectory: 'coverage',