diff --git a/.github/workflows/CI_backend.yml b/.github/workflows/CI_backend.yml new file mode 100644 index 0000000..575dcd1 --- /dev/null +++ b/.github/workflows/CI_backend.yml @@ -0,0 +1,42 @@ +# worflow for building the back end + +name: "Java backend CI" # the name of the job when ran + +# events that will trigger this workflow to run +on: + push: + branches: [ "main", "develop"] + paths: # only trigger if changes in this paths + - 'backend/**' + pull_request: + branches: [ "main", "develop"] + paths: + - 'backend/**' + +env: + java_version: 17 + java_distribution: temurin +defaults: + run: + working-directory: ./backend +# run in parallel by default +# can be multiple jobs +# cannot share machines between jobs so either steps or need to check out in each job +jobs: + build: # first job + runs-on: ubuntu-latest # the "worker node" where it's going to be build + steps: + - name: Check out code + uses: actions/checkout@v4.1.7 # action + + - name: Set up jdk ${{ env.java_version }} + uses: actions/setup-java@v4 + with: + java-version: ${{ env.java_version }} + distribution: ${{ env.java_distribution }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: Build with Gradle + run: ./gradlew build diff --git a/.github/workflows/CI_frontend.yml b/.github/workflows/CI_frontend.yml new file mode 100644 index 0000000..43c1dd8 --- /dev/null +++ b/.github/workflows/CI_frontend.yml @@ -0,0 +1,60 @@ +# worflow for building the front end + +name: "React frotend CI" # the name of the job when ran + +# events that will trigger this workflow to run +on: + push: + branches: [ "main", "develop"] + paths: # only trigger if changes in this paths + - 'frontend/**' + pull_request: + branches: [ "main", "develop"] + paths: + - 'frontend/**' +env: + node_version: 22.x +defaults: + run: + working-directory: ./frontend + +# run in parallel by default +# can be multiple jobs +# cannot share machines between jobs so either steps or need to check out in each job +jobs: + build: # first job + runs-on: ubuntu-latest # the "worker node" where it's going to be build + steps: + - name: Check out code + uses: actions/checkout@v4.1.7 # action + + - name: Use Node.js ${{ env.node_version }} + uses: actions/setup-node@v4.0.3 # action + with: + node-version: ${{ env.node_version }} + cache: 'npm' + cache-dependency-path: './frontend/package-lock.json' + + - name: Run npm clean install + run: npm ci + + # can have or not a name + - run: npm run build --if-present + + # test job + test: + needs: build + runs-on: ubuntu-latest # the "worker node" where it's going to be build + steps: + - name: Check out code + uses: actions/checkout@v4.1.7 # action + + - name: Use Node.js ${{ env.node_version }} + uses: actions/setup-node@v4.0.3 # action + with: + node-version: ${{ env.node_version }} + cache: 'npm' + cache-dependency-path: './frontend/package-lock.json' + - name: "Run test on frontend" + run: npm ci + - run: npm test \ No newline at end of file diff --git a/backend/HELP.md b/backend/HELP.md index 97d9dcb..041a679 100644 --- a/backend/HELP.md +++ b/backend/HELP.md @@ -1,4 +1,4 @@ -# Getting Started +# Getting Started with Java and gradle ### Reference Documentation For further reference, please consider the following sections: diff --git a/backend/src/main/java/demo/containers/workshop/controllers/HelloController.java b/backend/src/main/java/demo/containers/workshop/controllers/HelloController.java index 770f8bf..e150717 100644 --- a/backend/src/main/java/demo/containers/workshop/controllers/HelloController.java +++ b/backend/src/main/java/demo/containers/workshop/controllers/HelloController.java @@ -8,7 +8,7 @@ public class HelloController { @GetMapping("/") public String index() { - return "Greetings from Spring Boot!"; + return "Greetings from Spring Boot!!"; } } \ No newline at end of file diff --git a/frontend/src/App.test.js b/frontend/src/App.test.js index 1f03afe..fbe1be8 100644 --- a/frontend/src/App.test.js +++ b/frontend/src/App.test.js @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import App from './App'; -test('renders learn react link', () => { +test('renders learn react link in app page', () => { render(); const linkElement = screen.getByText(/learn react/i); expect(linkElement).toBeInTheDocument();