chore(deps): update NPM dependencies #392
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
name: Build & Test Container | |
on: | |
pull_request: ~ | |
env: | |
IMAGE_NAME: oscal-editor-all-in-one | |
CONTAINER_NAME: test_container | |
jobs: | |
lint: | |
name: Lint the code base | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
cache: "npm" | |
cache-dependency-path: "end-to-end-tests/package.json" | |
- name: Globally update npm | |
run: npm install -g npm@latest | |
working-directory: end-to-end-tests | |
- name: Install dependencies | |
run: npm ci | |
working-directory: end-to-end-tests | |
- name: Install lint dependencies | |
run: | | |
npm install -g markdownlint-cli | |
pip install yamllint | |
working-directory: end-to-end-tests | |
- name: Lint code base | |
run: | | |
# Run built-in JavaScript/JSON linting | |
npm run lint | |
working-directory: end-to-end-tests | |
build_test: | |
name: Build and Test All-in-One Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Install Tools | |
run: | | |
sudo apt-get update | |
sudo apt-get install jq xmlstarlet curl wget | |
# Get Default OSCAL Content for testing | |
- name: Pull OSCAL Content | |
uses: actions/checkout@v3 | |
with: | |
repository: EasyDynamics/oscal-demo-content | |
ref: "test-content" | |
path: all-in-one/oscal-content | |
- name: Set Up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Build the Docker image, and load it locally so it can be run for testing | |
- name: Build Docker Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./all-in-one | |
load: true | |
provenance: false | |
tags: ${{ env.IMAGE_NAME }} | |
# Run container in the background, exposing the port that | |
# Cypress uses to run the tests. | |
- name: Run Docker Container for Tests | |
run: | | |
chmod -R go+w $(pwd)/all-in-one/oscal-content; | |
ls -al $(pwd)/all-in-one/oscal-content; | |
docker run --rm -p 8080:8080 \ | |
-v $(pwd)/all-in-one/oscal-content:/app/oscal-content \ | |
--name ${CONTAINER_NAME} ${IMAGE_NAME} & | |
# Give the container time to start before starting to hammer it with tests | |
- name: Wait 10 sec | |
run: | | |
sleep 10 | |
- name: Run Cypress Tests | |
uses: cypress-io/github-action@v5 | |
with: | |
spec: cypress/e2e/**/*.cy.js | |
working-directory: end-to-end-tests | |
- name: Emit Docker Container Logs to file | |
if: always() | |
run: | | |
docker logs ${CONTAINER_NAME} &> container-logs.txt | |
- name: Upload Docker Container Logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-logs | |
path: container-logs.txt | |
# Upload the screenshots and videos of a Cypress test failure | |
# to the artifacts of this workflow on GitHub | |
- name: Upload Cypress Artifacts | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: cypress-results | |
path: | | |
./end-to-end-tests/cypress/screenshots | |
./end-to-end-tests/cypress/videos | |
- name: Stop Running Container | |
run: docker stop ${CONTAINER_NAME} |