From 5f28bf5ccf94c70dc6b17e367a46dbb945b38ae0 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Wed, 15 Jan 2025 23:16:49 +0530 Subject: [PATCH 1/7] Matrix Builds GH Workflow --- .github/workflows/matrix-build.yml | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/matrix-build.yml diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml new file mode 100644 index 0000000..701737a --- /dev/null +++ b/.github/workflows/matrix-build.yml @@ -0,0 +1,31 @@ +# This workflow uses actions that are not certified by GitHub. They are +# provided by a third-party and are governed by separate terms of service, +# privacy policy, and support documentation. +# +# This workflow will install a prebuilt Ruby version, install dependencies, and +# run tests and linters. + +name: CI Pipeline + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: [3.0, 3.1] + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - name: Install dependencies + run: bundle install + + - name: Run Tests + run: rails test \ No newline at end of file From 9bbf1bf1e8bdc3bda76808e613f44653f46bc994 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Wed, 15 Jan 2025 23:36:37 +0530 Subject: [PATCH 2/7] Matrix ruby updated --- .github/workflows/matrix-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml index 701737a..008fb50 100644 --- a/.github/workflows/matrix-build.yml +++ b/.github/workflows/matrix-build.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [3.0, 3.1] + ruby: ["3.0.3", 3.1] steps: - name: Checkout code uses: actions/checkout@v2 From c52a93a9dc9c9d43665aa3e5a0feff832be9eef5 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Wed, 15 Jan 2025 23:39:11 +0530 Subject: [PATCH 3/7] Compactibile ruby --- .github/workflows/matrix-build.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml index 008fb50..048e483 100644 --- a/.github/workflows/matrix-build.yml +++ b/.github/workflows/matrix-build.yml @@ -1,11 +1,4 @@ -# This workflow uses actions that are not certified by GitHub. They are -# provided by a third-party and are governed by separate terms of service, -# privacy policy, and support documentation. -# -# This workflow will install a prebuilt Ruby version, install dependencies, and -# run tests and linters. - -name: CI Pipeline +name: Matrix Build Workflow on: [push] @@ -14,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ["3.0.3", 3.1] + ruby: ["3.0.3"] steps: - name: Checkout code uses: actions/checkout@v2 From 69c1d1e7288dc8518d50652c6851ae736cf439e0 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Wed, 15 Jan 2025 23:40:19 +0530 Subject: [PATCH 4/7] Workflow triggers changed --- .github/workflows/matrix-build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml index 048e483..d34499f 100644 --- a/.github/workflows/matrix-build.yml +++ b/.github/workflows/matrix-build.yml @@ -1,6 +1,10 @@ name: Matrix Build Workflow -on: [push] +on: + push: + branches: [main] + pull_request: + branches: [main] jobs: build: From c1a32908022bba2ad9af8eb60345b5bc2f6414f3 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Thu, 16 Jan 2025 00:54:09 +0530 Subject: [PATCH 5/7] PSQL service changes --- .github/workflows/matrix-build.yml | 44 ++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml index d34499f..973c528 100644 --- a/.github/workflows/matrix-build.yml +++ b/.github/workflows/matrix-build.yml @@ -12,6 +12,23 @@ jobs: strategy: matrix: ruby: ["3.0.3"] + + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: ${{ secrets.DATABASE_USERNAME }} + POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} + POSTGRES_DB: myapp_test + options: >- + --mount type=tmpfs,destination=/var/lib/postgresql/data + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: - name: Checkout code uses: actions/checkout@v2 @@ -21,8 +38,29 @@ jobs: with: ruby-version: ${{ matrix.ruby }} + # Install dependencies - name: Install dependencies - run: bundle install + run: | + gem install bundler + bundle install + + # Set environment variables for database connection + - name: Set database connection environment variables + run: | + echo "DATABASE_URL=postgres://${{ secrets.DATABASE_USERNAME }}:${{ secrets.DATABASE_PASSWORD }}@localhost:5432/myapp_test" >> $GITHUB_ENV + echo "RAILS_ENV=test" >> $GITHUB_ENV + + # Create the database + - name: Create the database + run: | + bin/rails db:create + + # Run migrations + - name: Run migrations + run: | + bin/rails db:migrate - - name: Run Tests - run: rails test \ No newline at end of file + # Run Tests + - name: Run tests + run: | + bin/rails test From df0bee260e0cedc280b157f08379abad0c3123c5 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Thu, 16 Jan 2025 01:02:12 +0530 Subject: [PATCH 6/7] check failure case --- .github/workflows/matrix-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml index 973c528..d416454 100644 --- a/.github/workflows/matrix-build.yml +++ b/.github/workflows/matrix-build.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ["3.0.3"] + ruby: ["3.0.3", "3.1.0"] services: postgres: From 3ee5201a47f0e22903c48adea1294245bc08a610 Mon Sep 17 00:00:00 2001 From: Varun Gadde Date: Thu, 16 Jan 2025 01:31:38 +0530 Subject: [PATCH 7/7] commented the demo change --- .github/workflows/matrix-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/matrix-build.yml b/.github/workflows/matrix-build.yml index d416454..4e26b46 100644 --- a/.github/workflows/matrix-build.yml +++ b/.github/workflows/matrix-build.yml @@ -11,7 +11,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: ["3.0.3", "3.1.0"] + ruby: ["3.0.3"] + # ruby: ["3.0.3", "3.1.0"] services: postgres: