Skip to content

Commit d3619fc

Browse files
committed
feat: Enhance GitHub Actions workflows with caching for Node and Composer dependencies, and add TypeScript transformation job
1 parent 7ff1e97 commit d3619fc

File tree

5 files changed

+92
-3
lines changed

5 files changed

+92
-3
lines changed

.github/actions/setup-server/action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ runs:
2828
uses: actions/setup-node@v4
2929
with:
3030
node-version: '${{ inputs.node-version }}'
31-
cache: 'npm'
31+
32+
- name: Cache Node Modules
33+
uses: actions/cache@v4
34+
with:
35+
path: node_modules
36+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
37+
restore-keys: |
38+
${{ runner.os }}-node-
3239
3340
- name: Install Node Dependencies
3441
shell: bash
@@ -38,6 +45,14 @@ runs:
3845
shell: bash
3946
run: npm run build
4047

48+
- name: Cache Composer Dependencies
49+
uses: actions/cache@v4
50+
with:
51+
path: vendor
52+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
53+
restore-keys: |
54+
${{ runner.os }}-php-
55+
4156
- name: Install Composer Dependencies
4257
shell: bash
4358
run: composer install --no-interaction --prefer-dist --optimize-autoloader

.github/workflows/locals.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/checkout@v4
1818

1919
- name: Setup Server
20-
uses: ./actions/setup-server
20+
uses: ./.github/actions/setup-server
2121

2222
- name: Check Missing Translations for ${{ matrix.locals }}
2323
run: |

.github/workflows/packages.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check Dependency Updates
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * 1-5' # Every weekday at 4 AM UTC
6+
workflow_dispatch: # Allows manual triggering
7+
8+
jobs:
9+
check-composer-updates:
10+
name: Check PHP Composer Updates
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up PHP 8.4
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.4' # change to latest if 8.4 not yet stable
20+
tools: composer:v2
21+
22+
- name: Install composer dependencies (no dev)
23+
run: composer install --no-dev --no-progress --no-scripts
24+
25+
- name: Show outdated PHP packages
26+
run: composer outdated --direct
27+
28+
check-npm-updates:
29+
name: Check Node (NPM) Updates
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- name: Set up Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
cache: 'npm'
40+
41+
- name: Install dependencies using package-lock.json
42+
run: npm ci
43+
44+
- name: Show outdated JS packages
45+
run: npm outdated

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: actions/checkout@v4
1414

1515
- name: Setup Server
16-
uses: ./actions/setup-server
16+
uses: ./.github/actions/setup-server
1717

1818
- name: Tests
1919
run: ./vendor/bin/phpunit
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: typescript-transform
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
types:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Server
15+
uses: ./.github/actions/setup-server
16+
17+
- name: Run TypeScript transformation
18+
run: |
19+
generated_types=$(mktemp)
20+
php artisan typescript:transform --silent --output="$generated_types" || true
21+
22+
current_types=$(cat "$GITHUB_WORKSPACE/resources/js/types/generated.d.ts")
23+
24+
if [ "$(tr -d '[:space:]' < "$generated_types")" != "$(echo "$current_types" | tr -d '[:space:]')" ]; then
25+
echo "Generated types differ from current types."
26+
echo "Differences:"
27+
diff -u <(echo "$current_types") <(cat "$generated_types") || true
28+
exit 1
29+
fi

0 commit comments

Comments
 (0)