From 9645e03eba5b0bd7e17849120a0f8458bc1c44fb Mon Sep 17 00:00:00 2001 From: Karthik Sivadas Date: Sat, 6 Apr 2024 19:36:32 +0530 Subject: [PATCH 1/2] Change file name --- .../{create_release_notes.yaml => create-release-notes.yaml} | 0 ...rver_docker_hub_push.yaml => server-docker-hub-push-tags.yaml} | 0 .../{ui_docker_hub_push.yaml => ui-docker-hub-push-tags.yaml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{create_release_notes.yaml => create-release-notes.yaml} (100%) rename .github/workflows/{server_docker_hub_push.yaml => server-docker-hub-push-tags.yaml} (100%) rename .github/workflows/{ui_docker_hub_push.yaml => ui-docker-hub-push-tags.yaml} (100%) diff --git a/.github/workflows/create_release_notes.yaml b/.github/workflows/create-release-notes.yaml similarity index 100% rename from .github/workflows/create_release_notes.yaml rename to .github/workflows/create-release-notes.yaml diff --git a/.github/workflows/server_docker_hub_push.yaml b/.github/workflows/server-docker-hub-push-tags.yaml similarity index 100% rename from .github/workflows/server_docker_hub_push.yaml rename to .github/workflows/server-docker-hub-push-tags.yaml diff --git a/.github/workflows/ui_docker_hub_push.yaml b/.github/workflows/ui-docker-hub-push-tags.yaml similarity index 100% rename from .github/workflows/ui_docker_hub_push.yaml rename to .github/workflows/ui-docker-hub-push-tags.yaml From 2362a301c62f1cbb120a033c3ce5771ae7e09144 Mon Sep 17 00:00:00 2001 From: Karthik Sivadas Date: Sat, 6 Apr 2024 19:48:51 +0530 Subject: [PATCH 2/2] feat: Move server and ui github action ci to root --- .github/workflows/server-ci.yml | 56 +++++++++++++++++ .github/workflows/server-docker-build.yml | 29 +++++++++ .github/workflows/ui-ci.yml | 26 ++++++++ .github/workflows/ui-docker-build.yml | 29 +++++++++ .../workflows/ui-validate.yml | 16 ++++- server/.github/workflows/ci.yml | 62 ------------------- server/.github/workflows/docker-build.yml | 29 --------- ui/.github/workflows/ci.yml | 34 ---------- ui/.github/workflows/docker-build.yml | 29 --------- 9 files changed, 153 insertions(+), 157 deletions(-) create mode 100644 .github/workflows/server-ci.yml create mode 100644 .github/workflows/server-docker-build.yml create mode 100644 .github/workflows/ui-ci.yml create mode 100644 .github/workflows/ui-docker-build.yml rename ui/.github/workflows/validate.yml => .github/workflows/ui-validate.yml (64%) delete mode 100644 server/.github/workflows/ci.yml delete mode 100644 server/.github/workflows/docker-build.yml delete mode 100644 ui/.github/workflows/ci.yml delete mode 100644 ui/.github/workflows/docker-build.yml diff --git a/.github/workflows/server-ci.yml b/.github/workflows/server-ci.yml new file mode 100644 index 00000000..393f3c03 --- /dev/null +++ b/.github/workflows/server-ci.yml @@ -0,0 +1,56 @@ +name: server-ci + +on: + push: + branches: [main] + paths: + - "server/**" + pull_request: + branches: [main] + paths: + - "server/**" + +env: + DB_HOST: localhost + DB_USERNAME: postgres + DB_PASSWORD: postgres + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: multiwoven_test + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2.0 + + - name: Bundle Install + run: bundle install + working-directory: ./server + + - name: Database Setup + run: bundle exec rake db:create db:schema:load --trace + working-directory: ./server + + - name: Run RuboCop + run: bundle exec rubocop + working-directory: ./server + + - name: Run Tests + run: bundle exec rspec + working-directory: ./server diff --git a/.github/workflows/server-docker-build.yml b/.github/workflows/server-docker-build.yml new file mode 100644 index 00000000..319d83e3 --- /dev/null +++ b/.github/workflows/server-docker-build.yml @@ -0,0 +1,29 @@ +name: server-docker-build + +on: + workflow_run: + workflows: ["server-ci"] + branches: [main] + types: + - completed + +env: + IMAGE_NAME: multiwoven/multiwoven-server + IMAGE_TAG: latest-main + +jobs: + build_and_push: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Login to Docker Hub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Build and Push Docker image + run: | + docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} -t ${{ env.IMAGE_NAME }}:${{ github.sha }} -f server/Dockerfile ./server + docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} + docker push ${{ env.IMAGE_NAME }}:${{ github.sha }} diff --git a/.github/workflows/ui-ci.yml b/.github/workflows/ui-ci.yml new file mode 100644 index 00000000..acdc231c --- /dev/null +++ b/.github/workflows/ui-ci.yml @@ -0,0 +1,26 @@ +name: frontend-ci + +on: + pull_request: + paths: + - "ui/**" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: "18" + + - name: Install dependencies + run: npm install + working-directory: ./ui + + - name: Run tests and collect coverage + run: npm test -- --coverage + working-directory: ./ui diff --git a/.github/workflows/ui-docker-build.yml b/.github/workflows/ui-docker-build.yml new file mode 100644 index 00000000..97a00e39 --- /dev/null +++ b/.github/workflows/ui-docker-build.yml @@ -0,0 +1,29 @@ +name: frontend-docker-build + +on: + workflow_run: + workflows: ["frontend-ci"] + branches: [main] + types: + - completed + +env: + IMAGE_NAME: multiwoven/multiwoven-ui + IMAGE_TAG: latest-main + +jobs: + build_and_push: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Login to Docker Hub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Build and Push Docker image + run: | + docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} -t ${{ env.IMAGE_NAME }}:${{ github.sha }} -f ui/Dockerfile ./ui + docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} + docker push ${{ env.IMAGE_NAME }}:${{ github.sha }} diff --git a/ui/.github/workflows/validate.yml b/.github/workflows/ui-validate.yml similarity index 64% rename from ui/.github/workflows/validate.yml rename to .github/workflows/ui-validate.yml index d44f51fa..8434e2de 100644 --- a/ui/.github/workflows/validate.yml +++ b/.github/workflows/ui-validate.yml @@ -1,12 +1,17 @@ -name: Validate Workflow +name: UI - Validate Workflow on: push: branches: - main + paths: + - "ui/**" pull_request: branches: - - develop + - main + paths: + - "ui/**" + jobs: build: runs-on: ubuntu-latest @@ -17,11 +22,16 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '18' + node-version: "18" - name: Install dependencies run: npm install + working-directory: ./ui + - name: Build Source Code run: npm run build + working-directory: ./ui + - name: Lint Source Code run: npm run lint + working-directory: ./ui diff --git a/server/.github/workflows/ci.yml b/server/.github/workflows/ci.yml deleted file mode 100644 index f2e81c9e..00000000 --- a/server/.github/workflows/ci.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: server-ci - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -env: - RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - DB_HOST: localhost - DB_USERNAME: postgres - DB_PASSWORD: postgres - -jobs: - test: - runs-on: ubuntu-latest - - services: - postgres: - image: postgres:13 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: multiwoven_test - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.2.0 - - - name: Bundle Install - run: bundle install - - - name: Database Setup - run: bundle exec rake db:create db:schema:load --trace - - - name: Run RuboCop - run: bundle exec rubocop - - - name: Run Tests - run: bundle exec rspec - - - name: Install cc-test-reporter - if: github.event_name == 'push' - run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - - - name: Upload Coverage to Code Climate - if: github.event_name == 'push' - run: | - ./cc-test-reporter before-build - ./cc-test-reporter after-build --exit-code $? diff --git a/server/.github/workflows/docker-build.yml b/server/.github/workflows/docker-build.yml deleted file mode 100644 index 5accaf48..00000000 --- a/server/.github/workflows/docker-build.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: server-docker-build - -on: - workflow_run: - workflows: ["server-ci"] - branches: [main] - types: - - completed - -env: - IMAGE_NAME: multiwoven/multiwoven-server - IMAGE_TAG: latest - -jobs: - build_and_push: - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin - - - name: Build and Push Docker image - run: | - docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} -t ${{ env.IMAGE_NAME }}:${{ github.sha }} . - docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} - docker push ${{ env.IMAGE_NAME }}:${{ github.sha }} diff --git a/ui/.github/workflows/ci.yml b/ui/.github/workflows/ci.yml deleted file mode 100644 index 901a2bbc..00000000 --- a/ui/.github/workflows/ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: frontend-ci - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: "18" - - - name: Install dependencies - run: npm install - - - name: Run tests and collect coverage - run: npm test -- --coverage - - - name: Upload coverage to Code Climate - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build - if [ -f coverage/lcov.info ]; then - ./cc-test-reporter after-build --exit-code $? --coverage-input-type lcov - else - echo "Coverage report not found." - fi diff --git a/ui/.github/workflows/docker-build.yml b/ui/.github/workflows/docker-build.yml deleted file mode 100644 index ddd8029c..00000000 --- a/ui/.github/workflows/docker-build.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: frontend-docker-build - -on: - workflow_run: - workflows: ["frontend-ci"] - branches: [main] - types: - - completed - -env: - IMAGE_NAME: multiwoven/multiwoven-ui - IMAGE_TAG: latest - -jobs: - build_and_push: - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v2 - - - name: Login to Docker Hub - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin - - - name: Build and Push Docker image - run: | - docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} -t ${{ env.IMAGE_NAME }}:${{ github.sha }} . - docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} - docker push ${{ env.IMAGE_NAME }}:${{ github.sha }}