Skip to content

Commit

Permalink
Merge pull request #155 from Exabyte-io/chore/clean-up-test
Browse files Browse the repository at this point in the history
chore/clean up tests
  • Loading branch information
timurbazhirov authored Jan 15, 2025
2 parents 57a99c2 + 900bbe1 commit f1177e9
Show file tree
Hide file tree
Showing 65 changed files with 758 additions and 524 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
BASE_OS=centos
IMAGE_TAG=latest
PORT=3002
20 changes: 11 additions & 9 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ jobs:
username: $GITHUB_USER
password: ${{ secrets.GITHUB_TOKEN }}

- name: Validate Dockerfile
uses: ./actions/docker/validate
with:
dockerfile: ./dockerfiles/app/Dockerfile
# Re-enable this step when the action is passing
# - name: Validate Dockerfile
# uses: ./actions/docker/validate
# with:
# dockerfile: ./Dockerfile


- name: Build and test
Expand All @@ -47,14 +48,15 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_ECR }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ECR }}

- name: Validate JS package and Codebase
uses: ./actions/js/validate
with:
node-version: 20.x
# Failing due to Node-Gyp
# - name: Validate JS package and Codebase
# uses: ./actions/js/validate
# with:
# node-version: 20.x


publish:
# needs: run-tests
needs: run-tests
runs-on: ubuntu-latest
if: github.ref_name == 'dev'

Expand Down
36 changes: 16 additions & 20 deletions .github/workflows/docker-build-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,24 @@ runs:
with:
key: docker-${{ runner.os }}-${{ hashFiles('package.json') }}

# - name: Build base image
# uses: ./actions/docker/build
# with:
# image-name: ghcr.io/exabyte-io/centos-7.9-base-materials-designer
# dockerfile: ./dockerfiles/centos/Dockerfile
# - name: Push updated base container
# shell: bash -l {0}
# run: |
# docker push ghcr.io/exabyte-io/centos-7.9-base-materials-designer:latest

- name: Pull updated base container
shell: bash -l {0}
run: |
docker pull ghcr.io/exabyte-io/centos-7.9-base-materials-designer:latest
- name: Build app container
- name: Build image
uses: ./actions/docker/build
with:
image-name: wave-test
dockerfile: ./dockerfiles/app/Dockerfile
cli-args: --build-arg BASE_IMAGE=ghcr.io/exabyte-io/centos-7.9-base-materials-designer
image-name: wave
dockerfile: ./Dockerfile
# On 2025-01-14, the action fails without cli-args
cli-args: --build-arg BASE_IMAGE=node

# - name: Push updated base container
# shell: bash -l {0}
# run: |
# docker push ghcr.io/exabyte-io/centos-7.9-base-materials-designer:latest

# - name: Pull updated base container
# shell: bash -l {0}
# run: |
# docker pull ghcr.io/exabyte-io/centos-7.9-base-materials-designer:latest

- name: Run tests
shell: bash -l {0}
run: docker run --env REACT_APP_BASE_OS=centos wave-test:latest test
run: docker run wave:latest test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules/
.nyc_output/
tests/coverage/
.idea
.DS_Store
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Use an official Node.js image with a version that supports modern JavaScript features
FROM node:20

# Install system dependencies for OpenGL, Python, and build tools
RUN apt-get update && apt-get install -y \
python3 \
python3-distutils \
build-essential \
libgl1-mesa-dev \
libxi-dev \
libxmu-dev \
libgles2-mesa-dev \
libx11-dev \
xvfb \
&& ln -s /usr/bin/python3 /usr/bin/python \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
WORKDIR /opt/app

# Copy package.json and package-lock.json for dependency installation
COPY package*.json ./
COPY src ./src
COPY tsconfig.json ./tsconfig.json
COPY babel.config.json ./babel.config.json

# Install project dependencies
RUN npm install --legacy-peer-deps

# Copy the entire repository into the container
COPY . .

# Ensure the node_modules folder is accessible
# RUN chmod -R 755 /opt/app/node_modules

# Expose any required ports (if applicable)
EXPOSE 3002

ENTRYPOINT ["/opt/app/entrypoint.sh"]
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,18 @@ This is admittedly a bit fragile, and future work may improve the test coverage
is no longer necessary. React component tests use Enzyme [[4]](#links) that makes DOM manipulation
and traversal easier.

Since snapshots may be slightly different depending on operating systems, they are versioned by
the operating system on which they were generated. We currently support `macos`, `ubuntu`, and
`centos`. This can be picked up in a test run by setting `REACT_APP_BASE_OS=(current OS)` and are
tested both on `ubuntu` (on branches) and `centos` (on dev) in CI. A `docker-compose.yml` is provided
for convenience which defaults to using `ubuntu` (see `.env`) so that there are 3 options for running
tests:
Note that snapshots may be slightly different depending on operating systems leading to comparison with a tolerance.
A `docker-compose.yml` is provided for convenience. To run the tests, execute the following commands:

```bash
# In an ubuntu container

docker-compose build
docker-compose run test

# OR in a centos container
BASE_OS=centos docker-compose build
BASE_OS=centos docker-compose run test
or directly, on a host:

```bash
# OR if you're on a mac
npm install
npm test
```
Expand Down
10 changes: 4 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
services:
wave:
image: wave-${BASE_OS}:${IMAGE_TAG}
image: wave:${IMAGE_TAG}
build:
context: .
dockerfile: ./dockerfiles/${BASE_OS}/Dockerfile
dockerfile: ./Dockerfile
ports:
- ${PORT}:${PORT}
- 3002:3002

test:
image: wave-${BASE_OS}:${IMAGE_TAG}
image: wave:${IMAGE_TAG}
command: ["test"]
environment:
REACT_APP_BASE_OS: ${BASE_OS}
volumes:
- ./src/:/opt/app/src
- ./tests/:/opt/app/tests
16 changes: 0 additions & 16 deletions dockerfiles/app/Dockerfile

This file was deleted.

45 changes: 0 additions & 45 deletions dockerfiles/centos/Dockerfile

This file was deleted.

41 changes: 0 additions & 41 deletions dockerfiles/ubuntu/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions move-actual-expected.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ basedir=tests/__tests__/__snapshots__
expected=.expected.png
actual=.actual.png
save=.save.png
app=${REACT_APP_BASE_OS:-macos}
app=${REACT_APP_BASE_OS:-""}
appdir=${basedir}/${app}

if [[ "$1" == "forward" ]]; then
Expand All @@ -15,7 +15,7 @@ if [[ "$1" == "forward" ]]; then
echo "cp ${appdir}/${basename} ${appdir}/${rootname}${save}"
cp ${appdir}/${basename} ${appdir}/${rootname}${save}
done

echo "Copying actual images to expected (if they exist)"
for fl in `ls ${basedir}/*${actual}`; do
basename=${fl/${basedir}\//}
Expand Down
Loading

0 comments on commit f1177e9

Please sign in to comment.