Open huixisheng opened 3 years ago
stages: - install-packages - lint - unit-test cache: # 缓存没有被 git 跟踪的文件 untracked: true policy: pull-push # https://docs.gitlab.com/ee/ci/caching/ # https://docs.gitlab.com/ce/ci/yaml/README.html#cache # GitLab CI/CD pipeline configuration reference | GitLab [https://docs.gitlab.com/ee/ci/yaml/README.html#cachekeyfiles](https://docs.gitlab.com/ee/ci/yaml/README.html#cachekeyfiles) key: files: - yarn.lock prefix: ${CI_JOB_NAME} paths: - node_modules install-packages: stage: install-packages cache: policy: pull-push paths: - node_modules tags: - unit-test script: - yarn --silent unit-test: stage: unit-test cache: policy: pull paths: - node_modules script: - yarn test tags: - unit-test only: - master - /^release.*$/ - /^feature.*$/ - merge_requests coverage: /All files\s*\|\s*([\d\.]+)/ lint: stage: lint only: - master - /^release.*$/ - /^feature.*$/ - merge_requests cache: policy: pull paths: - node_modules script: - yarn lint tags: - unit-test
每次要修改 NODE_MODULES_VERSION 还是比较麻烦的
# 定义 stages stages: - install-packages - lint - unit-test # https://docs.gitlab.com/ee/ci/variables/#using-predefined-environment-variables variables: NODE_MODULES_VERSION: "project-1.0.0" cache: untracked: true policy: pull-push # https://docs.gitlab.com/ee/ci/caching/ # https://docs.gitlab.com/ce/ci/yaml/README.html#cache key: "$NODE_MODULES_VERSION" paths: - node_modules install-packages: stage: install-packages cache: policy: pull-push paths: - node_modules # 根据自己实际情况配置 tags: - unit-test script: - yarn --silent unit-test: stage: unit-test # https://segmentfault.com/a/1190000016483568 cache: policy: pull paths: - node_modules script: - yarn test # 根据自己实际情况配置 tags: - unit-test only: - master - /^release.*$/ - /^feature.*$/ - merge_requests coverage: /All files\s*\|\s*([\d\.]+)/ lint: stage: lint # https://segmentfault.com/a/1190000010442764#item-1-1 only: - master - /^release.*$/ - /^feature.*$/ - merge_requests cache: policy: pull paths: - node_modules script: - yarn lint # 根据自己实际情况配置 tags: - unit-test
最佳实践
历史方案