Skip to content

Commit

Permalink
chore: github action for docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
hdescottes committed Dec 28, 2024
1 parent ff379f5 commit 7874f31
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 87 deletions.
179 changes: 99 additions & 80 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,88 +7,107 @@ on:
- master

jobs:
build-backend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
build-frontend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node 18.x
uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: npm
cache-dependency-path: app-ui/package-lock.json
- name: Install dependencies
run: npm install -D puppeteer karma-chrome-launcher --save-dev @babel/preset-typescript
working-directory: app-ui
- name: Build
run: npm run build
working-directory: app-ui
- name: Test
run: npm run test --no-watch --no-progress --browsers=ChromeHeadlessCI
working-directory: app-ui
# build-backend:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
#
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: "17"
# distribution: "adopt"
# - name: Validate Gradle wrapper
# uses: gradle/wrapper-validation-action@v3
# - name: Cache Gradle packages
# uses: actions/cache@v4
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
# - name: Build with Gradle
# run: ./gradlew build
# - name: Cleanup Gradle Cache
# # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# # Restoring these files from a GitHub Actions cache might cause problems for future builds.
# run: |
# rm -f ~/.gradle/caches/modules-2/modules-2.lock
# rm -f ~/.gradle/caches/modules-2/gc.properties
#
# build-frontend:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v4
#
# - name: Use Node 18.x
# uses: actions/setup-node@v4
# with:
# node-version: "18.x"
# cache: npm
# cache-dependency-path: app-ui/package-lock.json
# - name: Install dependencies
# run: npm install -D puppeteer karma-chrome-launcher --save-dev @babel/preset-typescript
# working-directory: app-ui
# - name: Build
# run: npm run build
# working-directory: app-ui
# - name: Test
# run: npm run test --no-watch --no-progress --browsers=ChromeHeadlessCI
# working-directory: app-ui
#
# cypress-run:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: "17"
# distribution: "adopt"
#
# - name: Start Backend server
# run: ./gradlew bootRun --args='--spring.profiles.active=e2e' &
#
# - name: Cypress run
# uses: cypress-io/github-action@v6
# with:
# working-directory: app-ui
# build: npm run build
# start: npm start
#
# - name: Upload screenshots
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: cypress-screenshots
# path: /home/runner/work/StockMarketDashboard/StockMarketDashboard/app-ui/cypress/screenshots
#
# - name: Stop Backend server
# run: curl -X POST http://localhost:8080/actuator/shutdown
# if: always()

cypress-run:
docker-compose:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"

- name: Start Backend server
run: ./gradlew bootRun --args='--spring.profiles.active=e2e' &

- name: Cypress run
uses: cypress-io/github-action@v6
with:
working-directory: app-ui
build: npm run build
start: npm start

- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: /home/runner/work/StockMarketDashboard/StockMarketDashboard/app-ui/cypress/screenshots

- name: Stop Backend server
run: curl -X POST http://localhost:8080/actuator/shutdown
if: always()
- name: Install typescript
working-directory: ./app-ui
run: npm i typescript
- name: Run Docker-compose
working-directory: ./docker
run: |
docker compose -f docker-compose.yml up -d
sleep 5
docker compose -f docker-compose.yml ps
- name: Check UI
run: curl http://localhost:3000
- name: Stop and remove containers
run: docker compose -f docker-compose.yml down
13 changes: 6 additions & 7 deletions app-ui/package-lock.json

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

2 changes: 2 additions & 0 deletions app-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^6.3.0",
"@mui/material": "^6.0.2",
"@mui/types": "^7.2.20",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.2",
Expand Down Expand Up @@ -58,6 +59,7 @@
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@babel/preset-typescript": "^7.26.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"babel-jest": "^29.7.0",
Expand Down

0 comments on commit 7874f31

Please sign in to comment.