2023-02-22 11:42:39 +01:00
|
|
|
name: Test action build
|
2023-02-21 12:18:52 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
|
|
|
|
jobs:
|
2023-02-22 11:42:39 +01:00
|
|
|
test-build:
|
2023-04-30 21:37:33 +02:00
|
|
|
name: Build the action and run TypeScript tests
|
2023-02-21 12:18:52 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout the action
|
2024-03-19 19:30:33 +01:00
|
|
|
uses: actions/checkout@v4
|
2023-02-21 12:18:52 +01:00
|
|
|
- name: Setup Node.js 16.x
|
2024-03-19 18:35:22 +01:00
|
|
|
uses: actions/setup-node@v4
|
2023-02-21 12:18:52 +01:00
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
- name: Install npm-cli-login
|
|
|
|
run: npm install -g npm-cli-login
|
|
|
|
- name: Login to GitHub npm registry
|
2023-02-26 14:25:42 +01:00
|
|
|
# Both username and email address are irrelevant here, but they must be
|
|
|
|
# specified because otherwise npm-cli-login fails.
|
2023-02-21 12:18:52 +01:00
|
|
|
run: |
|
|
|
|
npm-cli-login -s @actions-rs -r https://npm.pkg.github.com \
|
2023-02-26 14:25:42 +01:00
|
|
|
-u does_not_matter -p ${{ secrets.GITHUB_TOKEN }} -e does_not_m@ter.com
|
2023-02-21 12:18:52 +01:00
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
2023-04-30 21:37:33 +02:00
|
|
|
- name: Rebuild the action and run tests
|
2023-02-22 11:42:39 +01:00
|
|
|
run: npm run all
|
|
|
|
- name: Compare the expected and actual src/ directories
|
|
|
|
run: |
|
|
|
|
if [ "$(git diff src/ | wc -l)" -gt "0" ]; then
|
|
|
|
echo "Source files are not properly formatted!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
id: diff_src
|
|
|
|
- name: Upload the expected version of src/ in case of failure
|
2024-03-19 18:30:32 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-02-22 11:42:39 +01:00
|
|
|
if: ${{ failure() && steps.diff_src.conclusion == 'failure' }}
|
|
|
|
with:
|
|
|
|
name: expected-src
|
|
|
|
path: src/
|
2023-02-21 12:18:52 +01:00
|
|
|
- name: Compare the expected and actual dist/ directories
|
|
|
|
run: |
|
|
|
|
if [ "$(git diff dist/ | wc -l)" -gt "0" ]; then
|
2023-02-22 11:42:39 +01:00
|
|
|
echo "Built sources do not match the content of the dist/ directory!"
|
2023-02-21 12:18:52 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-02-22 11:42:39 +01:00
|
|
|
id: diff_dist
|
|
|
|
- name: Upload the expected version of dist/ in case of failure
|
2024-03-19 18:30:32 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-02-22 11:42:39 +01:00
|
|
|
if: ${{ failure() && steps.diff_dist.conclusion == 'failure' }}
|
2023-02-21 12:18:52 +01:00
|
|
|
with:
|
|
|
|
name: expected-dist
|
|
|
|
path: dist/
|