Skip to content

Optimize docker images #454

Optimize docker images

Optimize docker images #454

Workflow file for this run

---
name: Integration
on:
push:
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
jobs:
pre:
# Verification to be done before the real check
name: Pre-check
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_flag.outputs.should_skip }}
steps:
- name: Skip flag
id: skip_flag
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: "same_content_newer"
paths: '["client/**", "client-e2e/**", ".github/workflows/integrate.yml"]'
build:
name: Build/Test
needs: pre
if: needs.pre.outputs.should_skip != 'true'
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup npm, yarn etc.
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install docker and docker-compose
run: |
sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/v2.11.2/docker-compose-linux-x86_64"
sudo chmod +x /usr/local/bin/docker-compose
- name: Cache docker images
uses: ScribeMD/[email protected]
with:
key: |
docker-${{ runner.os }}-${{ hashFiles(
'docker-compose*.yml',
'client/Dockerfile',
'client-e2e/Dockerfile',
'client-e2e/images/Dockerfile.*'
) }}
- name: Setup for running tests
run: |
IP=$(ip address show eth0 | grep inet | cut -d ' ' -f 6 | cut -d '/' -f1 | head -n1)
printf "HOST_IP address is: %s\n" "$IP"
cat <<EOF >> ./.env
HOST_IP="$IP"
EOF
cat <<EOF >> ./client/.env
NODE_ENV=development
MAILBOX_URL="wss://mailbox.stage.mw.leastauthority.com/v1"
RELAY_URL="wss://relay.stage.mw.leastauthority.com"
EOF
printf "Client .env:\n"
cat ./client/.env
printf "Client-e2e .env:\n"
cat ./.env
- name: Set up containers
run: |
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e build --build-arg uid="$(id -u)" --build-arg gid="$(id -g)"
docker compose run --rm client npm i
docker compose run --rm client ./scripts/setup.sh
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e run --rm client-e2e npm i
- name: Start up devserver
run: |
docker compose up -d client
docker compose exec client ./scripts/wait-for-webpack.sh
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run UNIT and INTEGRATION tests
run: docker compose run --rm client npm run test -- --coverage
- name: Run END-2-END tests
run: |
docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e run --rm client-e2e
- name: Stop the containers
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml --profile e2e down
- uses: sonarsource/sonarqube-scan-action@master
# if: github.ref_name == 'main' && github.event_name == 'push'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}