Tired of waiting over 10 minutes just to see your test failed 🤣? Now you can make it in 5.
The CI in CI/CD refers to continuous integrations, an automation process for developers. Favorably considered testing, merging, linting, etc. It's a solution to the problem of confining to a standardized flow of development.
The CD in CI/CD refers to continuous deliveries/deployments, which is the step after "CI". Automating the deploying process to a specific development, staging, and production environments.
By using GitHub actions, we are allowed to use an action marketplace that provides a ton of actions to improve our workflow. For example, actions/setup-node provides node runtime environment on GitHub actions.
name: CI without cache
on: workflow_dispatch
jobs:
ci:
name: Running CI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3.0.2
- uses: actions/setup-node@v3.1.1
with:
node-version: v16.14.2
- run: yarn install
### Run test/lint etc.
- run: yarn test
name: CI cache
on: workflow_dispatch
jobs:
ci:
name: Running CI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3.0.2
- uses: actions/setup-node@v3.1.1
with:
node-version: v16.14.2
cache: 'yarn'
# Useful for caching dependencies in monorepos
cache-dependency-path: yarn.lock
- run: yarn install
- run: yarn test
NOTE: Now actions/setup-node has native supports for caching
name: CI cache advance
on: workflow_dispatch
jobs:
ci:
name: Running CI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3.0.2
- uses: actions/setup-node@v3.1.1
with:
node-version: v16.14.2
- name: Get node version
id: node
run: |
echo "::set-output name=version::$(node -v)"
- name: Get node_modules cache
uses: actions/cache@v3.0.2
id: node_modules
with:
path: |
**/node_modules
# Adding node version as cache key
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }}-${{ steps.node.outputs.version }}
- run: yarn install
- run: yarn test
Note: Caching dependencies will reflect only if the dependencies are the same on the 2nd or n(th) run.
From us to your inbox weekly.