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

TMEDIA-580 test only changed files on push and in actions #1210

Merged
merged 15 commits into from
Jan 7, 2022
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
53 changes: 53 additions & 0 deletions .github/workflows/test-coverage-blocks-canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test Blocks - Changed from Canary Base

on:
pull_request:
# synchronize commit(s) pushed to the pull request
types: [synchronize, opened]
# only prs targeting canary
# test:changed-feature-branch currently only targets canary for changed files
branches: [canary]

jobs:
ensure_minimum_test_coverage_linting:
runs-on: ubuntu-latest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
# 0 indicates all history for all branches and tags
fetch-depth: 0

- name: Setup Node with 12
uses: actions/setup-node@v1
with:
node-version: "12"
registry-url: "https://npm.pkg.github.com"

- name: Cache Node Modules
id: cache
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}

- name: Clean install (CI) dependencies if lockfile (above) changed
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

- name: Run tests on changed since canary with coverage
run: npm run test:changed-feature-branch

- name: Check linting
run: npm run lint

- name: Check failure status
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
if: failure()
7 changes: 5 additions & 2 deletions .github/workflows/test-coverage-blocks.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Test News Theme Blocks
name: Test Blocks and Linting - Everything

on:
pull_request:
# synchronize commit(s) pushed to the pull request
types: [synchronize, opened]
# ignores prs to canary, runs on other branches
branches: [stable, rc, beta]

jobs:
ensure_minimum_test_coverage_linting:
Expand Down Expand Up @@ -34,6 +36,7 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}

# all tests run
- name: Run tests with coverage
run: npm run test:coverage

Expand All @@ -44,4 +47,4 @@ jobs:
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
if: failure()
if: failure()
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
6 changes: 6 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# changed-feature-branch is only for targeting canary at the moment
# todo: run lint only on changed files
# fetching latest changes to ensure the origin/canary is up to date
npm run lint && git fetch -a --depth 100 && npm run test:changed-feature-branch
8 changes: 0 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ module.exports = {
functions: 85,
lines: 85,
},
// if an output type breaks, the page doesn't load
// this should be higher, really
'blocks/default-output-block/output-types': {
statements: 86,
branches: 80,
functions: 100,
lines: 85,
},
},
collectCoverageFrom: [
'**/(features|chains|layouts|sources|output-types|_children|components|utils)/**/*.{js,jsx}',
Expand Down
Loading