0.10.0 #50
This file contains 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
# Continuous Integration (CI) Workflow | |
name: ci | |
# See: | |
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#on | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
jobs: | |
lint: | |
name: ESLint | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/actions/checkout | |
- name: Check out code | |
uses: actions/checkout@v3 | |
# https://github.com/actions/setup-node | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
# Use node LTS version 18 - https://github.com/actions/setup-node#supported-version-syntax | |
node-version: '18' | |
# Cache npm dependencies so they don't have to be downloaded next time - https://github.com/actions/setup-node#caching-packages-dependencies | |
cache: 'npm' | |
- name: Install node dependencies | |
#See: https://docs.npmjs.com/cli/v8/commands/npm-ci | |
run: npm ci | |
- name: Run ESLint | |
run: npm run lint | |
# Lint Dockerfile using Hadolint | |
dockerfile-lint: | |
name: Dockerfile Lint | |
runs-on: ubuntu-latest | |
steps: | |
# https://github.com/marketplace/actions/hadolint-action | |
- uses: actions/checkout@v3 | |
- uses: hadolint/hadolint-action@v3.1.0 | |
with: | |
dockerfile: Dockerfile | |
unit-tests: | |
name: Unit Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install node dependencies and run Tests | |
# There are two ways to do this: | |
# 1. run: | | |
# - npm install | |
# - npm test | |
#2. Use `install-ci-test` to do it in a single command, see https://docs.npmjs.com/cli/v8/commands/npm-install-ci-test | |
run: npm install-ci-test | |
integration-tests: | |
name: Integration Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install node dependencies | |
# NOTE: we need to install dev dependencies too vs. production only for hurl | |
run: npm install | |
- name: Build Containers | |
run: docker compose up -d | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }} | |
AWS_DYNAMODB_TABLE_NAME: fragments | |
- name: Setup Local AWS Resources | |
run: | | |
chmod +x ./scripts/local-aws-setup.sh | |
./scripts/local-aws-setup.sh | |
- name: Run Hurl Tests | |
run: npm run test:integration | |
docker-hub: | |
name: Build and Push Image to Docker Hub | |
needs: [lint, dockerfile-lint, unit-tests, integration-tests] | |
runs-on: ubuntu-latest | |
steps: | |
# Set up buildx for optimal Docker Builds, see: | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Build and Push an Image to Docker Hub | |
- name: Build and push | |
env: | |
DOCKERHUB_REPO: mdmytrenko/fragments | |
# Define current git commit's sha | |
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | |
SHA_TAG: sha-${{ github.sha }} | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
# Use 3 tags: :latest-commit-sha, :main, and :latest | |
tags: ${{ env.DOCKERHUB_REPO }}:${{ env.SHA_TAG }}, ${{ env.DOCKERHUB_REPO }}:main, ${{ env.DOCKERHUB_REPO }}:latest |