Skip to content

ci(tests.yml): Update check for Dockerfile and yarn.lock changes #128

ci(tests.yml): Update check for Dockerfile and yarn.lock changes

ci(tests.yml): Update check for Dockerfile and yarn.lock changes #128

Workflow file for this run

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test-local:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js v18 (LTS)
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Lint the source files
run: yarn lint
- name: Type check
run: yarn type-check
- name: Build the library
run: yarn build
- name: Build the typings
run: yarn build:types
- name: Execute the tests
run: |
yarn test:unit
yarn test:functional
test-docker:
runs-on: ubuntu-latest
env:
IMAGE_TARGET: tester
IMAGE_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Check for changes in Dockerfile
id: diff
run: |
git fetch origin main
echo 'DOCKERFILE_CHANGED='$(git diff --name-only origin/main HEAD | grep -qE '(Dockerfile|yarn.lock)' && echo true || echo false) >> $GITHUB_ENV
- name: Build Docker image
uses: docker/build-push-action@v5
if: ${{ env.DOCKERFILE_CHANGED == 'true' }}
with:
push: true
context: .
target: ${{ env.IMAGE_TARGET }}
tags: ${{ env.IMAGE_TAG }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Execute the tests in a container
run: docker run --rm ${{ env.IMAGE_TAG }} ./test-functional/test-strings.ci.js