Created
December 1, 2024 21:45
-
-
Save LuksJobs/ea8cddb935bdf7a0df7c3c398f2bbb16 to your computer and use it in GitHub Desktop.
No **GitLab CI/CD**, tanto **artifacts** quanto **cache** são recursos que ajudam no gerenciamento de arquivos durante as etapas de uma pipeline. Apesar de terem funcionalidades parecidas em alguns casos, existem diferenças importantes em como eles funcionam e para que são usados. Entender essas diferenças permite utilizá-los de forma mais efici…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stages: | |
| - build | |
| - test | |
| 📦 build_job: | |
| stage: build | |
| image: node:22.11 | |
| script: | |
| ## Instalando as depedências necessárias do Projeto | |
| - echo "🚀 Instalando as depedências do projeto ..." | |
| - npm install | |
| ## Buildando o Projeto | |
| - echo "📦 Buildando o Projeto ..." | |
| - npm run build | |
| cache: | |
| paths: | |
| - node_modules/ | |
| key: "$CI_COMMIT_REF_SLUG" # Cache específico por branch | |
| artifacts: | |
| paths: | |
| - dist/ # Diretório com arquivos de build | |
| expire_in: 30 minutes # Os artifacts expiram após 30 minutos | |
| 🛠️ test_job: | |
| stage: test | |
| image: node:22.11 | |
| script: | |
| ## Executando os testes unitários | |
| - echo "🛠️ Executando os testes unitários ..." | |
| - npm test | |
| cache: | |
| paths: | |
| - node_modules/ # Reaproveita o mesmo cache | |
| key: "$CI_COMMIT_REF_SLUG" # Deve ser igual ao build_job | |
| dependencies: | |
| - 📦 build_job # Pega os artifacts do job anterior |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment