Skip to content

Commit

Permalink
Merge pull request #57 from Exabyte-io/feature/SOF-5466
Browse files Browse the repository at this point in the history
Feature/sof-5466
  • Loading branch information
tjduigna committed Mar 4, 2022
2 parents 2e8078c + 8db990b commit d5397bf
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 47 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,32 @@ jobs:
with:
lfs: true

- name: Docker build and test
uses: ./.github/workflows/docker-build-test

- name: Checkout actions repository
uses: actions/checkout@v2
with:
repository: Exabyte-io/actions
token: ${{ secrets.BOT_GITHUB_TOKEN }}
path: actions

- name: Docker build and test
uses: ./.github/workflows/docker-build-test
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_ECR }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ECR }}

- name: Validate JS package
uses: ./actions/js/validate

- name: Validate app dockerfile
uses: ./actions/docker/validate
with:
dockerfile: ./dockerfiles/app/Dockerfile

- name: Validate test dockerfile
uses: ./actions/docker/validate
with:
dockerfile: ./dockerfiles/app/test/Dockerfile

publish:
needs: run-tests
runs-on: ubuntu-latest
Expand Down
39 changes: 31 additions & 8 deletions .github/workflows/docker-build-test/action.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
name: Build docker containers and run tests
inputs:
aws-access-key-id:
required: true
aws-secret-access-key:
required: true

runs:
using: composite
steps:
- name: Pull base image
uses: ./actions/docker/ecr
id: login-ecr
with:
ecr-repository: centos-7.9-base
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
image-tag: latest
action: pull

- name: Build application container
shell: bash -l {0}
run: docker-compose build materials-designer
uses: ./actions/docker/build
with:
image-name: materials-designer
dockerfile: ./dockerfiles/app/Dockerfile
cli-args: --build-arg BASE_IMAGE=${{ steps.login-ecr.outputs.registry }}/centos-7.9-base


- name: Build test container
shell: bash -l {0}
run: docker-compose build materials-designer-test
uses: ./actions/docker/build
with:
image-name: materials-designer-test
dockerfile: ./dockerfiles/app/test/Dockerfile
cli-args: --build-arg BASE_IMAGE=${{ steps.login-ecr.outputs.registry }}/centos-7.9-base


- name: Run tests
shell: bash -l {0}
run: |
docker-compose up -d materials-designer
while ! docker logs materials-designer_materials-designer_1 2>&1 | grep "Compiled"; do
failed=$(docker logs materials-designer_materials-designer_1 2>&1 | grep "Failed")
docker run -d -p 3001:3001 --name=materials-designer materials-designer:latest
while ! docker logs materials-designer 2>&1 | grep "Compiled"; do
failed=$(docker logs materials-designer 2>&1 | grep "Failed")
if [[ "$failed" != "" ]]; then
exit 1
fi
sleep 5
done
docker-compose run materials-designer-test
docker run --network=host materials-designer-test
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,13 @@ the `entrypoint.sh` you may need to re-build both containers for your changes to
work. It can also be useful to comment out the `ENTRYPOINT` in the `centos` dockerfile
as well as the `CMD` in the `test` dockerfile in order to easily run and debug both
containers. There is also a `docker-compose.yml` file which can be used for local
building and testing. See `.github/workflows/cicd.yml` for example uses.
building and testing. Provided `docker-compose` is installed, it can be used like so:

```bash
docker-compose build materials-designer
docker-compose build materials-designer-test

docker-compose up -d materials-designer
sleep 30 # let the app actually start
docker-compose run materials-designer-test
```
17 changes: 17 additions & 0 deletions dockerfiles/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG BASE_IMAGE
ARG IMAGE_TAG=latest
FROM ${BASE_IMAGE}:${IMAGE_TAG}

WORKDIR /opt/app

COPY . .

RUN source scl_source enable devtoolset-8 && \
npm install

EXPOSE 3001

RUN bash core-js-fix.sh

ENTRYPOINT ["/opt/app/entrypoint.sh"]

36 changes: 36 additions & 0 deletions dockerfiles/app/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ARG BASE_IMAGE
ARG IMAGE_TAG=latest
FROM ${BASE_IMAGE}:${IMAGE_TAG}

ENV NODE_VERSION $TEST_NODE_VERSION
ENV NPM_VERSION $TEST_NPM_VERSION

ARG NVM=${NVM_DIR}/nvm.sh
RUN . $NVM && \
nvm use v$NODE_VERSION && \
npm install -g npm@$NPM_VERSION
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

WORKDIR /opt/test
RUN git init
COPY . .

WORKDIR /opt/test/tests
RUN source scl_source enable devtoolset-8 && npm install


# This is an interesting hack. There is a bug in the function
# to getLinuxChromeDriverArchitecture causing a comparison between
# a number and a string when two strings are expected.
RUN sed -i "s/if(compareVersions(version,/if(compareVersions(String(version),/" \
node_modules/selenium-standalone/lib/compute-download-urls.js


# Entrypoint was previously defined in /opt/app so overwrite
# it for easiest test container development and just pass along a flag
# to kick off the tests instead of running the application
WORKDIR /opt/test
ENV BASE_DIR /opt/test
ENTRYPOINT ["/opt/test/entrypoint.sh", "test"]

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 38 additions & 32 deletions tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d5397bf

Please sign in to comment.