Skip to content

Commit 785e504

Browse files
committed
Optimize docker smoke CI image reuse
1 parent 34f7e0c commit 785e504

2 files changed

Lines changed: 37 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,41 +104,56 @@ jobs:
104104
- name: Run frontend smoke test
105105
run: npm run test:e2e
106106

107-
docker-test:
107+
docker-build-smoke-image:
108108
needs:
109109
- hadolint
110110
- ruby
111111
- openapi
112112
- frontend
113113
runs-on: ubuntu-latest
114+
steps:
115+
- uses: actions/checkout@v6
116+
117+
- name: Build Docker smoke image
118+
run: docker build -t html2rss/web -f Dockerfile .
119+
120+
- name: Export Docker smoke image
121+
run: docker save html2rss/web -o /tmp/html2rss-web-smoke-image.tar
122+
123+
- name: Upload Docker smoke image
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: docker-smoke-image
127+
path: /tmp/html2rss-web-smoke-image.tar
128+
retention-days: 1
129+
130+
docker-test:
131+
needs:
132+
- docker-build-smoke-image
133+
runs-on: ubuntu-latest
114134
strategy:
115135
fail-fast: false
116136
matrix:
117137
smoke_auto_source_enabled: ["false", "true"]
118138
steps:
119-
- uses: actions/checkout@v5
139+
- uses: actions/checkout@v6
120140

121141
- uses: ruby/setup-ruby@v1
122142
with:
123143
bundler-cache: true
124144

125-
- name: Setup Node.js for Docker smoke test
126-
uses: actions/setup-node@v4
145+
- name: Download Docker smoke image
146+
uses: actions/download-artifact@v4
127147
with:
128-
node-version-file: ".tool-versions"
129-
cache: npm
130-
cache-dependency-path: frontend/package-lock.json
131-
132-
- name: Install frontend dependencies
133-
run: npm ci
134-
working-directory: frontend
148+
name: docker-smoke-image
149+
path: /tmp
135150

136-
- name: Build frontend static assets
137-
run: npm run build
138-
working-directory: frontend
151+
- name: Load Docker smoke image
152+
run: docker load -i /tmp/html2rss-web-smoke-image.tar
139153

140154
- name: Run Docker smoke test
141155
env:
156+
DOCKER_SMOKE_SKIP_BUILD: "true"
142157
SMOKE_AUTO_SOURCE_ENABLED: ${{ matrix.smoke_auto_source_enabled }}
143158
run: bundle exec rake
144159

Rakefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ task :test do
4747
current_dir = ENV.fetch('GITHUB_WORKSPACE', __dir__)
4848
smoke_auto_source_enabled = ENV.fetch('SMOKE_AUTO_SOURCE_ENABLED', 'false')
4949
image_name = 'html2rss/web'
50+
skip_build = ENV.fetch('DOCKER_SMOKE_SKIP_BUILD', 'false') == 'true'
51+
52+
if skip_build
53+
Output.describe 'Running with prebuilt docker image'
54+
else
55+
Output.describe 'Building and running'
56+
sh "docker build -t #{image_name} -f Dockerfile ."
57+
end
5058

51-
Output.describe 'Building and running'
52-
sh "docker build -t #{image_name} -f Dockerfile ."
5359
sh ['docker run',
5460
'-d',
5561
'-p 4000:4000',

0 commit comments

Comments
 (0)