Skip to content

Commit

Permalink
chore: update workflow files (#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche authored Feb 4, 2025
1 parent e4b826c commit 3d7005a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 26 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Cache
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * *'

jobs:
refresh:
runs-on: ubuntu-latest
steps:
- if: >
github.event_name == 'schedule'
name: 🧹🪣 Delete caches
run: gh cache delete --all
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
- name: ⬇️ Checkout package.json
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
package.json
- id: install
name: 📥 Install deps
run: yarn
env:
HUSKY_SKIP_INSTALL: true
- if: >
steps.install.outcome == 'success'
name: ♻️ Save node_modules
uses: actions/cache/save@v4
with:
path: |
yarn.lock
node_modules
key: ${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
72 changes: 47 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
name: CI
on:
push:
branches:
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
'beta',
'alpha',
'!all-contributors/**',
]
branches-ignore: ['all-contributors/**']
pull_request:
branches-ignore: ['all-contributors/**']

jobs:
validate:
runs-on: ubuntu-latest
if: >
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.fork
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
- name: 📥 Download deps
uses: bahmutov/npm-install@v1
uses: actions/checkout@v4
- id: restore
name: ♻️ Restore node_modules
uses: actions/cache/restore@v4
with:
useLockFile: false
install-command: yarn --silent
path: |
yarn.lock
node_modules
key: ${{ hashFiles('package.json') }}
restore-keys: ${{ hashFiles('package.json') }}-

- id: install
if: >
steps.restore.outputs.cache-matched-key == ''
name: 📥 Install deps
run: yarn
env:
HUSKY_SKIP_INSTALL: true
- if: >
steps.install.outcome == 'success'
name: ♻️ Save node_modules
uses: actions/cache/save@v4
with:
path: |
yarn.lock
node_modules
key: ${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
- name: ✍ Lint
run: npm run lint
Expand All @@ -38,24 +52,30 @@ jobs:
- name: 🏗 Build
run: npm run build

- name: ⬆️ Upload coverage report
uses: codecov/codecov-action@v1
- name: ☂️ Upload coverage report
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

release:
needs: validate
runs-on: ubuntu-latest
if:
${{ github.repository == 'testing-library/user-event' &&
if: >
github.event_name == 'push' &&
github.repository == 'testing-library/user-event' &&
contains('refs/heads/main,refs/heads/beta,refs/heads/alpha', github.ref)
&& github.event_name == 'push' }}
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v2
- name: 📥 Download deps
uses: bahmutov/npm-install@v1
uses: actions/checkout@v4
- name: ♻️ Restore node_modules
uses: actions/cache/restore@v4
with:
useLockFile: false
install-command: yarn --silent
path: |
yarn.lock
node_modules
key: ${{ runner.os }}-${{ hashFiles('package.json') }}
- name: 📥 Install deps
run: yarn
env:
HUSKY_SKIP_INSTALL: true

Expand All @@ -64,6 +84,8 @@ jobs:

- name: 🚀 Release
uses: ph-fritsche/action-release@v2
with:
dry: ${{ vars.RELEASE_DRY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
'*.+(json|yml|yaml|css|less|scss|md|gql|graphql|mdx|vue)': [
'*.+(json|css|less|scss|md|gql|graphql|mdx|vue)': [
`kcd-scripts format`,
],
'*.+(js|jsx|mjs|cjs|ts|tsx|mts|cts)': [
Expand Down

0 comments on commit 3d7005a

Please sign in to comment.