Build the frontend once per pipeline and reuse it in the dev backend image [CI]
This commit is contained in:
1 parent
3654d37da5
commit
d1ece67a6a
5 files changed
+82
-6
No files matched your search
@@ -218,6 +218,27 @@ esac
|
||||
env['MOSHIRO_AOT_SLOT_WAIT'] = '5'
|
||||
self.assertEqual(subprocess.run(['bash', script, 'sh', '-c', 'exit 7'], env=env).returncode, 7)
|
||||
|
||||
def test_web_build_is_shared_with_the_backend_of_the_same_pipeline(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
temp = Path(temp)
|
||||
env = dict(os.environ, MOSHIRO_CI_STATE=str(temp / 'state'), CI_REPO_ID='1', CI_PIPELINE_NUMBER='2',
|
||||
MOSHIRO_SHARED_WEB_WAIT='1')
|
||||
script = ROOT / 'ci/shared-web.sh'
|
||||
# 复制一份脚本到假的仓库根,让它读写假的 web 目录
|
||||
fake = temp / 'repo'
|
||||
(fake / 'ci').mkdir(parents=True)
|
||||
(fake / 'ci/shared-web.sh').write_text(script.read_text())
|
||||
for app in ('display', 'admin'):
|
||||
(fake / 'web' / app / 'dist').mkdir(parents=True)
|
||||
(fake / 'web' / app / 'dist/index.html').write_text(app)
|
||||
run = lambda *args: subprocess.run(['bash', str(fake / 'ci/shared-web.sh'), *args], env=env, capture_output=True, text=True)
|
||||
self.assertEqual(run('fetch').returncode, 1)
|
||||
self.assertEqual(run('publish').returncode, 0)
|
||||
for app in ('display', 'admin'):
|
||||
(fake / 'web' / app / 'dist/index.html').unlink()
|
||||
self.assertEqual(run('fetch').returncode, 0)
|
||||
self.assertEqual((fake / 'web/admin/dist/index.html').read_text(), 'admin')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
||||
Reference in new issue
Block a user