forked from codevise/activeadmin-searchable_select
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (145 loc) · 5.66 KB
/
Copy pathci.yml
File metadata and controls
176 lines (145 loc) · 5.66 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: CI
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
ruby: ['3.3', '3.4', '4.0']
gemfile:
- rails_7.x_active_admin_4.x
- rails_8.x_active_admin_4.x
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
RAILS_ENV: test
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/ms-playwright
# Unique database suffix for parallel test execution
GITHUB_JOB: test-ruby${{ matrix.ruby }}-${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v5
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
# Install Playwright dependencies
- name: Install Playwright APT dependencies
run: |
sudo apt-get update
sudo apt-get install -y libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libdbus-1-3 libatspi2.0-0 libx11-6 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libgbm1 libxcb1 libxkbcommon0 libpango-1.0-0 libcairo2 libasound2t64
# Get Playwright version for cache key
- name: Get Playwright version
id: playwright-version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test 2>/dev/null | grep @playwright/test | sed 's/.*@//' | head -1)
if [ -z "$PLAYWRIGHT_VERSION" ]; then
PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //')
fi
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
# Cache Playwright browsers
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}-
${{ runner.os }}-playwright-
- name: Install npm dependencies
run: |
cd npm-package
npm install
- name: Build and install npm package
run: |
# Build the npm package
cd npm-package
npm pack
# Extract it to a temporary location
mkdir -p /tmp/npm-package
tar -xzf *.tgz -C /tmp/npm-package
# Update spec/internal to use the extracted package
cd ../spec/internal
# Remove any existing symlink/folder
rm -rf package
rm -rf node_modules/activeadmin-tom_select
npm install
# Install from the extracted package
npm install /tmp/npm-package/package
# Build assets (JS and CSS)
echo "Building JavaScript assets..."
npm run build:js
echo "Building CSS assets with Tailwind..."
bundle exec rake active_admin:build
# Verify assets were built
echo "Checking built assets..."
ls -la app/assets/builds/
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
cd npm-package
npx playwright install chromium
- name: Setup test database
run: |
cd spec/internal
./bin/rails db:create db:schema:load RAILS_ENV=test
- name: Run tests with coverage
run: |
bundle exec rspec --format progress --format RspecJunitFormatter --out rspec-results.xml
- name: Fix coverage paths for SonarQube
if: matrix.ruby == '3.4' && matrix.gemfile == 'rails_7.x_active_admin_4.x'
run: |
# SonarQube runs in Docker container where workspace is /github/workspace
# Coverage has paths like /home/runner/work/activeadmin-tom_select/activeadmin-tom_select/
# Need to replace GitHub runner paths with Docker container paths
if [ -f coverage/coverage.json ]; then
sed -i "s|/home/runner/work/activeadmin-tom_select/activeadmin-tom_select/|/github/workspace/|g" coverage/coverage.json
echo "Coverage paths fixed for SonarQube Docker container"
fi
- name: SonarQube Scan
if: matrix.ruby == '3.4' && matrix.gemfile == 'rails_7.x_active_admin_4.x' && github.event_name != 'pull_request'
uses: sonarsource/sonarqube-scan-action@v3
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL || 'https://sonarcloud.io' }}
with:
args: >
-Dsonar.projectKey=rs-pro_activeadmin-tom_select
-Dsonar.ruby.coverage.reportPaths=coverage/coverage.json
-Dsonar.ruby.rspec.reportPaths=rspec-results.xml
continue-on-error: true
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Run RuboCop
run: bundle exec rubocop --force-exclusion
build-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: npm-package/package-lock.json
- name: Install dependencies
run: |
cd npm-package
npm ci
- name: Check package
run: |
cd npm-package
npm pack --dry-run