-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
123 lines (112 loc) · 4.12 KB
/
setup-node-modules.yml
File metadata and controls
123 lines (112 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Reusable workflow for setting up node_modules
# This workflow installs dependencies and runs the project setup, then uploads
# the prepared node_modules as an artifact for consumption by other workflows.
name: Setup Node Modules
on:
workflow_call:
inputs:
ref:
description: 'Git ref to checkout (e.g., refs/pull/123/head or branch name)'
required: false
type: string
default: ''
fetch-depth:
description: 'Number of commits to fetch (0 for all history)'
required: false
type: number
default: 1
upload-artifact:
description: 'Whether to upload node_modules as an artifact'
required: false
type: boolean
default: true
artifact-name:
description: 'Name of the artifact to upload'
required: false
type: string
default: 'node-modules'
artifact-retention-days:
description: 'Number of days to retain the artifact'
required: false
type: number
default: 1
outputs:
artifact-name:
description: 'The actual artifact name used (includes node version and OS)'
value: ${{ jobs.setup.outputs.artifact-name }}
permissions:
contents: read
jobs:
setup:
name: Setup Node Modules
runs-on: ubuntu-latest
outputs:
artifact-name: ${{ steps.set-artifact-name.outputs.artifact-name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: ${{ inputs.fetch-depth }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set artifact name with node version and OS
id: set-artifact-name
run: |
NODE_VERSION=$(node --version | sed 's/v//')
OS_NAME=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
ARTIFACT_NAME="${{ inputs.artifact-name }}-node${NODE_VERSION}-${OS_NAME}"
echo "artifact-name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
echo "📦 Artifact name: $ARTIFACT_NAME"
- name: Install dependencies
run: |
echo "📦 Installing dependencies..."
yarn install --immutable
- name: Setup project
run: |
echo "🔧 Running setup for GitHub CI..."
yarn setup:github-ci
- name: Verify setup completed
run: |
echo "✅ Verifying setup artifacts..."
# Check that critical setup artifacts exist
if [ ! -d "node_modules" ]; then
echo "❌ node_modules directory not found"
exit 1
fi
if [ ! -f "app/util/termsOfUse/termsOfUseContent.ts" ]; then
echo "❌ Terms of Use content not generated"
exit 1
fi
if [ ! -f "app/core/InpageBridgeWeb3.js" ]; then
echo "❌ InpageBridgeWeb3.js not generated"
exit 1
fi
echo "🔍 Checking yarn setup..."
echo " Node version: $(node --version)"
echo " Yarn version: $(yarn --version)"
echo " Corepack version: $(corepack --version)"
echo "✅ Setup verification passed"
- name: Debug - List .yarn contents
run: |
echo "📂 Contents of .yarn directory:"
ls -la .yarn/ || echo "No .yarn directory"
echo "📊 .yarn size: $(du -sh .yarn 2>/dev/null || echo 'N/A')"
echo "📄 install-state.gz exists: $(test -f .yarn/install-state.gz && echo 'yes' || echo 'no')"
echo "📁 cache dir exists: $(test -d .yarn/cache && echo 'yes' || echo 'no')"
- name: Upload node_modules artifact
if: inputs.upload-artifact
uses: actions/upload-artifact@v4.5.0
with:
name: ${{ steps.set-artifact-name.outputs.artifact-name }}
path: |
node_modules
app/util/termsOfUse/termsOfUseContent.ts
app/core/InpageBridgeWeb3.js
scripts/inpage-bridge/dist
retention-days: ${{ inputs.artifact-retention-days }}
compression-level: 1
if-no-files-found: warn
include-hidden-files: true