Skip to content

Commit d53ea57

Browse files
committed
ci: improve e2e tests
1 parent d3e5b08 commit d53ea57

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

.github/workflows/reusable-test.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ jobs:
4040
if: steps.node_modules_cache.outputs.cache-hit != 'true'
4141
run: npm ci
4242

43+
- name: Check if artifact exists
44+
id: check_node_modules_artifact
45+
run: |
46+
ARTIFACT_NAME="modern-node-modules-${{ hashFiles('**/package-lock.json') }}"
47+
ARTIFACT_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
48+
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts" | \
49+
jq --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .id' | wc -l)
50+
51+
if [ "$ARTIFACT_EXISTS" -gt "0" ]; then
52+
echo "artifact_exists=true" >> $GITHUB_OUTPUT
53+
else
54+
echo "artifact_exists=false" >> $GITHUB_OUTPUT
55+
fi
56+
57+
- name: Upload node_modules to artifacts
58+
if: steps.check_node_modules_artifact.outputs.artifact_exists == 'false'
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: modern-node-modules-${{ hashFiles('**/package-lock.json') }}
62+
path: node_modules
63+
4364
# This job is used to run tests on modern Node.js versions
4465
# 1. Use default Node.js
4566
# 2. Install latest dependencies
@@ -63,27 +84,6 @@ jobs:
6384
path: node_modules
6485
key: ${{ runner.os }}-modern-node-modules-${{ hashFiles('**/package-lock.json') }}
6586

66-
- name: Check if artifact exists
67-
id: check_node_modules_artifact
68-
run: |
69-
ARTIFACT_NAME="modern-node-modules-${{ hashFiles('**/package-lock.json') }}"
70-
ARTIFACT_EXISTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
71-
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts" | \
72-
jq --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .id' | wc -l)
73-
74-
if [ "$ARTIFACT_EXISTS" -gt "0" ]; then
75-
echo "artifact_exists=true" >> $GITHUB_OUTPUT
76-
else
77-
echo "artifact_exists=false" >> $GITHUB_OUTPUT
78-
fi
79-
80-
- name: Upload node_modules to artifacts
81-
if: steps.check_node_modules_artifact.outputs.artifact_exists == 'false'
82-
uses: actions/upload-artifact@v4
83-
with:
84-
name: modern-node-modules-${{ hashFiles('**/package-lock.json') }}
85-
path: node_modules
86-
8787
- name: Build package
8888
run: npm run build
8989

0 commit comments

Comments
 (0)