-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathconfig.yml
More file actions
206 lines (182 loc) · 6.93 KB
/
config.yml
File metadata and controls
206 lines (182 loc) · 6.93 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Ruby CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
#
version: 2.1
# Cancel redundant builds when new commits are pushed
# This prevents multiple pipelines from racing to deploy
# Note: This must also be enabled in CircleCI project settings
# Settings > Advanced > Auto-cancel redundant builds
jobs:
build:
docker:
- image: cimg/ruby:3.2.8-browsers # Matches deployed Ruby version in CF
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
- image: cimg/redis:7.2.7
environment:
REDIS_URL: redis://redis:6379/1
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: cimg/postgres:15.8
environment:
POSTGRES_USER: root
POSTGRES_DB: touchpoints_test
parallelism: 4
working_directory: ~/repo
steps:
- run:
name: Update packages
command: sudo apt-get update
- run:
name: Ensure Chrome is available
command: |
# cimg/ruby:*-browsers images already include Chrome; skip orb command to avoid "Cannot find declaration" errors
echo "Using cimg/ruby:3.4.7-browsers which includes Chrome"
- checkout
- run:
name: Install Rust toolchain
command: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
echo 'source $HOME/.cargo/env' >> $BASH_ENV
source $HOME/.cargo/env
rustc --version
cargo --version
- restore_cache:
keys:
- v1-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}
- v1-cargo-
- run:
name: Build widget renderer (Rust)
command: |
source $HOME/.cargo/env
cargo build --release --manifest-path ext/widget_renderer/Cargo.toml
- run:
name: Verify Rust native library linkage
command: |
set -euo pipefail
LIB=ext/widget_renderer/target/release/libwidget_renderer.so
if [ -f "$LIB" ]; then
echo "Found built rust library; verifying linkage..."
if ldd "$LIB" 2>&1 | grep -q "not found"; then
echo "ERROR: Rust library has unresolved dependencies (ldd shows 'not found')."
ldd "$LIB" || true
exit 1
else
echo "Rust library linkage looks good"
fi
else
echo "No Rust library built - skipping linkage verification"
fi
- save_cache:
paths:
- ext/widget_renderer/target
- ~/.cargo/registry
- ~/.cargo/git
key: v1-cargo-{{ checksum "ext/widget_renderer/Cargo.lock" }}
# Download and cache dependencies
- restore_cache:
keys:
- v1-bundle-{{ checksum "Gemfile.lock" }}
- run: bundle install
- save_cache:
paths:
- ./vendor/bundle
key: v1-bundle-{{ checksum "Gemfile.lock" }}
# Database setup
- run: bundle exec rake db:create
- run: bundle exec rake db:schema:load
# Precompile assets (to use npm packages specified in assets.rb)
- run:
name: Precompile assets
command: |
npm i
rails assets:precompile
# run tests!
- run:
name: Run tests
command: |
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
# Install Cloud Foundry cli (cf) before deploy step. cf is used to push to Cloud.gov
- run:
name: Install-cf-cli
command: |
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: coverage
- run:
name: Deploy Sidekiq worker servers
command: |
# Only deploy from a single parallel node to avoid concurrent CF pushes.
if [ "${CIRCLE_NODE_INDEX:-0}" != "0" ]; then
echo "Skipping Sidekiq deploy on parallel node ${CIRCLE_NODE_INDEX}"
exit 0
fi
# Remove prebuilt Rust library - it must be built on CF with the correct Ruby paths
# The library built on CircleCI links against /usr/local/lib/libruby.so.3.2
# but on CF, Ruby is in /home/vcap/deps/*/ruby/lib/
echo "Removing prebuilt Rust library (will be rebuilt on CF)..."
rm -rf ext/widget_renderer/target/release/libwidget_renderer.so 2>/dev/null || true
rm -f ext/widget_renderer/libwidget_renderer.so 2>/dev/null || true
./.circleci/deploy-sidekiq.sh
no_output_timeout: 30m
- run:
name: Deploy web server(s)
command: |
# Only deploy from a single parallel node to avoid concurrent CF pushes.
if [ "${CIRCLE_NODE_INDEX:-0}" != "0" ]; then
echo "Skipping web deploy on parallel node ${CIRCLE_NODE_INDEX}"
exit 0
fi
# Wait for Sidekiq deployment to complete before starting web deploy
sleep 120
# Remove prebuilt Rust library - it must be built on CF with the correct Ruby paths
echo "Removing prebuilt Rust library (will be rebuilt on CF)..."
rm -rf ext/widget_renderer/target/release/libwidget_renderer.so 2>/dev/null || true
rm -f ext/widget_renderer/libwidget_renderer.so 2>/dev/null || true
./.circleci/deploy.sh
no_output_timeout: 30m
cron_tasks:
docker:
- image: cimg/base:2025.01
steps:
- checkout
- run:
name: Install-cf-cli
command: |
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
- run:
name: Run CRON tasks
command: ./.circleci/cron.sh
workflows:
daily_workflow:
triggers:
- schedule:
# cron: "0 * * * *" # every hour
cron: "0 11 * * *" # run at 6am est
# cron: "0 11,1 * * *" # at 6am est and 8pm est
filters:
branches:
only:
- production
jobs:
- cron_tasks
build-deploy:
jobs:
- build