|
1 | 1 | ## |
2 | 2 | # A reusable workflow that checks for uncommitted changes to built files in pull requests. |
3 | 3 | ## |
4 | | -name: Check Built Files (PRs) |
| 4 | +name: Check for Uncommitted Changes (PRs) |
5 | 5 |
|
6 | 6 | on: |
7 | 7 | workflow_call: |
@@ -108,96 +108,3 @@ jobs: |
108 | 108 | with: |
109 | 109 | name: pr-built-file-changes |
110 | 110 | path: changes.diff |
111 | | - |
112 | | - # Compares the results of npm run build with WordPress/WordPress |
113 | | - # |
114 | | - # Performs the following steps: |
115 | | - # - Checks out the repository. |
116 | | - # - Sets up Node.js. |
117 | | - # - Logs debug information about the GitHub Action runner. |
118 | | - # - Installs npm dependencies. |
119 | | - # - Builds WordPress to run from the build directory. |
120 | | - # - Ensures version-controlled files are not modified or deleted. |
121 | | - # - Checks out the WordPress/WordPress repository. |
122 | | - # - Creates a directory for text files to be uploaded as an artifact. |
123 | | - # - Storse a list of files that differ in the build directory from WordPress/WordPress. |
124 | | - # - Storse a diff file comparing the build directory to WordPress/WordPress. |
125 | | - # - Saves the pull request number to a text file. |
126 | | - # - Uploads the generated files as an artifact. |
127 | | - compare-built-files: |
128 | | - name: Detect differences between WordPress/WordPress |
129 | | - runs-on: ubuntu-24.04 |
130 | | - permissions: |
131 | | - contents: read |
132 | | - timeout-minutes: 10 |
133 | | - |
134 | | - steps: |
135 | | - - name: Checkout repository |
136 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
137 | | - with: |
138 | | - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
139 | | - persist-credentials: false |
140 | | - |
141 | | - - name: Set up Node.js |
142 | | - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 |
143 | | - with: |
144 | | - node-version-file: '.nvmrc' |
145 | | - cache: npm |
146 | | - |
147 | | - - name: Set up PHP |
148 | | - uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0 |
149 | | - with: |
150 | | - php-version: '8.4' |
151 | | - coverage: none |
152 | | - |
153 | | - # Since Composer dependencies are installed using `composer update` and no lock file is in version control, |
154 | | - # passing a custom cache suffix ensures that the cache is flushed at least once per week. |
155 | | - - name: Install Composer dependencies |
156 | | - uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0 |
157 | | - with: |
158 | | - custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F") |
159 | | - |
160 | | - - name: Log debug information |
161 | | - run: | |
162 | | - npm --version |
163 | | - node --version |
164 | | - git --version |
165 | | -
|
166 | | - - name: Install npm Dependencies |
167 | | - run: npm ci |
168 | | - |
169 | | - - name: Build WordPress to run from build directory |
170 | | - run: npm run build |
171 | | - |
172 | | - - name: Ensure version-controlled files are not modified or deleted |
173 | | - run: git diff --exit-code |
174 | | - |
175 | | - - name: Checkout WordPress/WordPress |
176 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
177 | | - with: |
178 | | - repository: 'WordPress/WordPress' |
179 | | - path: ${{ github.workspace }}/built-wordpress |
180 | | - show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
181 | | - persist-credentials: false |
182 | | - |
183 | | - - name: Create directory for artifacts |
184 | | - run: mkdir artifacts |
185 | | - |
186 | | - - name: Create a list of files that have changed |
187 | | - run: diff -rq ${{ github.workspace }}/build ${{ github.workspace }}/built-wordpress | sed "s|${{ github.workspace }}/||g" > artifacts/file-changes.txt |
188 | | - |
189 | | - - name: Create a list of files that have changed |
190 | | - run: diff -r ${{ github.workspace }}/build ${{ github.workspace }}/built-wordpress | sed "s|${{ github.workspace }}/||g" > artifacts/changes.diff |
191 | | - |
192 | | - - name: Save PR number |
193 | | - run: echo "${EVENT_NUMBER}" > ./artifacts/NR |
194 | | - env: |
195 | | - EVENT_NUMBER: ${{ github.event.number }} |
196 | | - |
197 | | - # Uploads the associated text files as an artifact. |
198 | | - - name: Upload comparison results as an artifact |
199 | | - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 |
200 | | - #if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }} |
201 | | - with: |
202 | | - name: build-script-comparison |
203 | | - path: artifacts/ |
0 commit comments