From 5b0c438b0abeb6caabbeed0232aea5d75ebbe7cb Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Mon, 14 Jul 2025 20:28:54 +0200 Subject: [PATCH 01/13] Use debian archive --- .github/workflows/release.yml | 6 +++--- .github/workflows/test_and_build.yml | 10 +++++----- index.js | 8 +++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61a56b0..3cdc440 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,8 +3,8 @@ name: Release on: [workflow_dispatch] jobs: - release: - runs-on: "ubuntu-20.04" + release: + runs-on: "ubuntu-22.04" steps: - uses: actions/checkout@v2 with: @@ -23,4 +23,4 @@ jobs: tag_schema: semantic env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: echo "Released ${{steps.create_release.outputs.current_tag}}" \ No newline at end of file + - run: echo "Released ${{steps.create_release.outputs.current_tag}}" diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index a8efd90..8ae137e 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -4,7 +4,7 @@ on: [push] jobs: test: - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" env: RACK_ENV: test PG_HOST: localhost @@ -23,13 +23,13 @@ jobs: ssh_key: "${{secrets.SSH_KEY_GITHUB}}" prod_apt_deps: true chrome: true - rubocop: true + rubocop: true postgres: true gem_server_credentials: "${{secrets.BUNDLE_GEMS__QUICKPAY__NET}}" gem_github_credentials: ${{secrets.BUNDLE_RUBYGEMS__PKG__GITHUB__COM}} set_env_var: true - uses: ruby/setup-ruby@v1 - with: + with: ruby-version: 2.7 - run: git clone git@github.com:QuickPay/klarna-payments-backend.git - run: gem install bundler @@ -39,7 +39,7 @@ jobs: build: needs: test runs-on: "ubuntu-20.04" - steps: + steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: @@ -51,4 +51,4 @@ jobs: REPO: self BRANCH: build FOLDER: dist - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/index.js b/index.js index fde425b..27bf9c5 100644 --- a/index.js +++ b/index.js @@ -20,11 +20,9 @@ async function run() { const envVar = getBool("set_env_var") if (chrome) { - cp.execSync(`sudo sh -c 'echo "deb http://deb.debian.org/debian buster main - deb http://deb.debian.org/debian buster-updates main - deb http://deb.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'` - ) - cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A`) + cp.execSync(`sudo sh -c 'echo "deb http://archive.debian.org/debian buster main\ndeb http://archive.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'`); + + cp.execSync(`sudo sh -c 'echo "Acquire::Check-Valid-Until \\"false\\";" > /etc/apt/apt.conf.d/99no-check-valid-until'`); cp.execSync(`sudo sh -c 'echo "# Note: 2 blank lines are required between entries Package: * Pin: release a=eoan From d4c54a471e20d768d77950e54abc8ad83b0ac5f4 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Mon, 14 Jul 2025 20:38:49 +0200 Subject: [PATCH 02/13] update node version --- .github/workflows/test_and_build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 8ae137e..e2a2daa 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v2 - uses: quickpay/postgresql-action@v2 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: "12" cache: "npm" @@ -41,7 +41,7 @@ jobs: runs-on: "ubuntu-20.04" steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: "12" cache: "npm" From d88002c8b8c3807cc8dcc930aaedcc80bc36a0f3 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Mon, 14 Jul 2025 20:44:30 +0200 Subject: [PATCH 03/13] use trusted=yes --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 27bf9c5..04ad8a0 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,7 @@ async function run() { const envVar = getBool("set_env_var") if (chrome) { - cp.execSync(`sudo sh -c 'echo "deb http://archive.debian.org/debian buster main\ndeb http://archive.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'`); + cp.execSync(`sudo sh -c 'echo "deb [trusted=yes] http://archive.debian.org/debian buster main\ndeb [trusted=yes] http://archive.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'`); cp.execSync(`sudo sh -c 'echo "Acquire::Check-Valid-Until \\"false\\";" > /etc/apt/apt.conf.d/99no-check-valid-until'`); cp.execSync(`sudo sh -c 'echo "# Note: 2 blank lines are required between entries From 3164a85cbfb360f8a267aacdd88ee2633f6f1dc6 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Mon, 14 Jul 2025 20:54:33 +0200 Subject: [PATCH 04/13] update bundler --- .github/workflows/test_and_build.yml | 2 +- index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index e2a2daa..f1fc94d 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -32,7 +32,7 @@ jobs: with: ruby-version: 2.7 - run: git clone git@github.com:QuickPay/klarna-payments-backend.git - - run: gem install bundler + - run: gem install bundler -v 2.4.22 - name: Tests run: cd integration_test && bundle install && bundle exec rake test - run: cd klarna-payments-backend && bundle install diff --git a/index.js b/index.js index 04ad8a0..5ad1cc1 100644 --- a/index.js +++ b/index.js @@ -20,9 +20,10 @@ async function run() { const envVar = getBool("set_env_var") if (chrome) { - cp.execSync(`sudo sh -c 'echo "deb [trusted=yes] http://archive.debian.org/debian buster main\ndeb [trusted=yes] http://archive.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'`); + cp.execSync(`sudo sh -c 'echo "deb http://archive.debian.org/debian buster main\ndeb http://archive.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'`); cp.execSync(`sudo sh -c 'echo "Acquire::Check-Valid-Until \\"false\\";" > /etc/apt/apt.conf.d/99no-check-valid-until'`); + cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A`) cp.execSync(`sudo sh -c 'echo "# Note: 2 blank lines are required between entries Package: * Pin: release a=eoan From 847adee8dcd2bab17672e3012d9a5cbd8b0527fb Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 13:45:19 +0200 Subject: [PATCH 05/13] use bullseye --- index.js | 8 ++--- integration_test/Gemfile.lock | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5ad1cc1..83c2d4f 100644 --- a/index.js +++ b/index.js @@ -20,10 +20,10 @@ async function run() { const envVar = getBool("set_env_var") if (chrome) { - cp.execSync(`sudo sh -c 'echo "deb http://archive.debian.org/debian buster main\ndeb http://archive.debian.org/debian-security buster/updates main" > /etc/apt/sources.list.d/debian.list'`); - - cp.execSync(`sudo sh -c 'echo "Acquire::Check-Valid-Until \\"false\\";" > /etc/apt/apt.conf.d/99no-check-valid-until'`); - cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A`) + cp.execSync(`sudo sh -c 'echo "deb http://deb.debian.org/debian bullseye main + deb http://deb.debian.org/debian bullseye-updates main + deb http://security.debian.org/debian-security bullseye-security main" > /etc/apt/sources.list.d/debian.list'`) + cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 54404762BBB6E853 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BDE6D2B9216EC7A8 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6ED0E7B82643E131 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 605C66F00D6C9793`); cp.execSync(`sudo sh -c 'echo "# Note: 2 blank lines are required between entries Package: * Pin: release a=eoan diff --git a/integration_test/Gemfile.lock b/integration_test/Gemfile.lock index 41fa2aa..26af54c 100644 --- a/integration_test/Gemfile.lock +++ b/integration_test/Gemfile.lock @@ -1,16 +1,77 @@ GEM remote: https://rubygems.org/ + remote: https://gems.quickpay.net/ + remote: https://rubygems.pkg.github.com/QuickPay/ specs: ansi (1.5.0) builder (3.2.4) + concurrent-ruby (1.3.5) + dry-configurable (0.16.1) + dry-core (~> 0.6) + zeitwerk (~> 2.6) + dry-container (0.11.0) + concurrent-ruby (~> 1.0) + dry-core (0.9.1) + concurrent-ruby (~> 1.0) + zeitwerk (~> 2.6) + dry-equalizer (0.3.0) + dry-inflector (0.3.0) + dry-initializer (3.1.1) + dry-logic (1.3.0) + concurrent-ruby (~> 1.0) + dry-core (~> 0.9, >= 0.9) + zeitwerk (~> 2.6) + dry-schema (1.10.6) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.13, >= 0.13.0) + dry-core (~> 0.5, >= 0.5) + dry-initializer (~> 3.0) + dry-logic (~> 1.2) + dry-types (~> 1.5) + dry-struct (1.4.0) + dry-core (~> 0.5, >= 0.5) + dry-types (~> 1.5) + ice_nine (~> 0.11) + dry-types (1.5.1) + concurrent-ruby (~> 1.0) + dry-container (~> 0.3) + dry-core (~> 0.5, >= 0.5) + dry-inflector (~> 0.1, >= 0.1.2) + dry-logic (~> 1.0, >= 1.0.2) + dry-validation (1.6.0) + concurrent-ruby (~> 1.0) + dry-container (~> 0.7, >= 0.7.1) + dry-core (~> 0.4) + dry-equalizer (~> 0.2) + dry-initializer (~> 3.0) + dry-schema (~> 1.5, >= 1.5.2) + excon (1.2.5) + logger + ice_nine (0.11.2) + json (2.13.0) + logger (1.7.0) minitest (5.14.4) minitest-reporters (1.4.3) ansi builder minitest (>= 5.0) ruby-progressbar + quickpay-ruby-client (3.0.2) + excon (>= 0.79) + json (~> 2, >= 2.5) + quickpay-stock (3.0.2) + dry-struct (~> 1.4.0) + dry-types (~> 1.5.1) + dry-validation (~> 1.6.0) + quickpay-ruby-client (~> 3.0.0) rake (13.0.6) ruby-progressbar (1.11.0) + stock (3.0.2) + dry-struct (~> 1.4.0) + dry-types (~> 1.5.1) + dry-validation (~> 1.6.0) + quickpay-ruby-client (~> 3.0.0) + zeitwerk (2.6.18) PLATFORMS ruby @@ -19,7 +80,9 @@ PLATFORMS DEPENDENCIES minitest minitest-reporters + quickpay-stock! rake + stock (~> 3.0.0)! BUNDLED WITH 2.2.27 From e951f7dfe55834a15f546e0d691eeb0ae89e0799 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 14:01:06 +0200 Subject: [PATCH 06/13] only import Bullseye keys --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 83c2d4f..c62189d 100644 --- a/index.js +++ b/index.js @@ -23,7 +23,7 @@ async function run() { cp.execSync(`sudo sh -c 'echo "deb http://deb.debian.org/debian bullseye main deb http://deb.debian.org/debian bullseye-updates main deb http://security.debian.org/debian-security bullseye-security main" > /etc/apt/sources.list.d/debian.list'`) - cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 54404762BBB6E853 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BDE6D2B9216EC7A8 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6ED0E7B82643E131 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 605C66F00D6C9793`); + cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 605C66F00D6C9793 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A48449044AAD5C5D && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 73A4F27B8DD47936 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 54404762BBB6E853 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BDE6D2B9216EC7A8`); cp.execSync(`sudo sh -c 'echo "# Note: 2 blank lines are required between entries Package: * Pin: release a=eoan From 9d2a525b93b7298394f57160fbf2731c9e33a5dc Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 14:14:20 +0200 Subject: [PATCH 07/13] add chromedriver manually --- index.js | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index c62189d..9b8caf3 100644 --- a/index.js +++ b/index.js @@ -20,28 +20,40 @@ async function run() { const envVar = getBool("set_env_var") if (chrome) { - cp.execSync(`sudo sh -c 'echo "deb http://deb.debian.org/debian bullseye main - deb http://deb.debian.org/debian bullseye-updates main - deb http://security.debian.org/debian-security bullseye-security main" > /etc/apt/sources.list.d/debian.list'`) - cp.execSync(`sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 605C66F00D6C9793 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A48449044AAD5C5D && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 73A4F27B8DD47936 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 54404762BBB6E853 && sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BDE6D2B9216EC7A8`); - cp.execSync(`sudo sh -c 'echo "# Note: 2 blank lines are required between entries -Package: * -Pin: release a=eoan -Pin-Priority: 500 + // Install Chrome + cp.execSync('wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb') + cp.execSync('sudo apt-get install -y ./google-chrome-stable_current_amd64.deb') -Package: * -Pin: origin "ftp.debian.org" -Pin-Priority: 300 + try { + const chromeVersionOutput = cp.execSync('google-chrome --version').toString() + console.log('Chrome version output:', chromeVersionOutput) -# Pattern includes 'chromium', 'chromium-browser' and similarly -# named dependencies: -Package: chromium* -Pin: origin "ftp.debian.org" -Pin-Priority: 700" > /etc/apt/preferences.d/chromium.pref'`) + const chromeVersionMatch = chromeVersionOutput.match(/\d+\.\d+\.\d+\.\d+/) + if (!chromeVersionMatch) { + throw new Error('Could not extract Chrome version from: ' + chromeVersionOutput) + } + const chromeVersion = chromeVersionMatch[0] + console.log('Chrome version:', chromeVersion) + + const chromedriverUrl = `https://storage.googleapis.com/chrome-for-testing-public/${chromeVersion}/linux64/chromedriver-linux64.zip` + console.log('Downloading chromedriver from:', chromedriverUrl) + + cp.execSync(`wget -q -O chromedriver.zip "${chromedriverUrl}"`) + cp.execSync('unzip -q chromedriver.zip') + cp.execSync('sudo mv chromedriver-linux64/chromedriver /usr/local/bin/') + cp.execSync('sudo chmod +x /usr/local/bin/chromedriver') + + cp.execSync('rm -rf chromedriver.zip chromedriver-linux64 google-chrome-stable_current_amd64.deb') + + console.log('Chromedriver installed successfully') + } catch (error) { + core.setFailed('Failed to install Chromedriver: ' + error.message) + return + } } if (chrome || prodAptDeps || postgres) { cp.execSync("DEBIAN_FRONTEND=noninteractive sudo apt-get update") - const aptDeps = (chrome ? ["chromium-chromedriver", "chromium"] : []) + const aptDeps = [] .concat(prodAptDeps ? [ "libpq-dev", "libcurl4-openssl-dev", @@ -52,7 +64,9 @@ Pin-Priority: 700" > /etc/apt/preferences.d/chromium.pref'`) "libsasl2-dev"] : []) .concat(postgres ? ["postgresql-client"] : []) .join(" ") - cp.execSync("DEBIAN_FRONTEND=noninteractive sudo apt-get install -y " + aptDeps) + if (aptDeps.length > 0) { + cp.execSync("DEBIAN_FRONTEND=noninteractive sudo apt-get install -y " + aptDeps) + } } if (sshKey) { cp.execSync("mkdir ~/.ssh") From 63d210359138736a5abcff22ce304e7e7ff92cd9 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 14:29:56 +0200 Subject: [PATCH 08/13] change gems source --- integration_test/Gemfile | 6 +----- integration_test/Gemfile.lock | 7 ------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/integration_test/Gemfile b/integration_test/Gemfile index 6f4078a..d8ebdd9 100644 --- a/integration_test/Gemfile +++ b/integration_test/Gemfile @@ -4,10 +4,6 @@ gem "minitest" gem "rake" gem "minitest-reporters" -source "https://gems.quickpay.net" do - gem "quickpay-stock" -end - -source "https://rubygems.pkg.github.com/QuickPay" do +source "https://rubygems.pkg.github.com/QuickPay" do gem "stock", "~> 3.0.0" end \ No newline at end of file diff --git a/integration_test/Gemfile.lock b/integration_test/Gemfile.lock index 26af54c..d9325fa 100644 --- a/integration_test/Gemfile.lock +++ b/integration_test/Gemfile.lock @@ -1,6 +1,5 @@ GEM remote: https://rubygems.org/ - remote: https://gems.quickpay.net/ remote: https://rubygems.pkg.github.com/QuickPay/ specs: ansi (1.5.0) @@ -59,11 +58,6 @@ GEM quickpay-ruby-client (3.0.2) excon (>= 0.79) json (~> 2, >= 2.5) - quickpay-stock (3.0.2) - dry-struct (~> 1.4.0) - dry-types (~> 1.5.1) - dry-validation (~> 1.6.0) - quickpay-ruby-client (~> 3.0.0) rake (13.0.6) ruby-progressbar (1.11.0) stock (3.0.2) @@ -80,7 +74,6 @@ PLATFORMS DEPENDENCIES minitest minitest-reporters - quickpay-stock! rake stock (~> 3.0.0)! From f1883fc728b9195539146bb03b8af530536dba75 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 15:01:28 +0200 Subject: [PATCH 09/13] update build to show logs --- .github/workflows/test_and_build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index f1fc94d..7020468 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -45,7 +45,12 @@ jobs: with: node-version: "12" cache: "npm" - - run: npm install && npm run build + - name: Install and build with verbose logging + run: | + echo "Starting npm install..." + npm install --verbose + echo "Starting npm build..." + npm run build --verbose - uses: s0/git-publish-subdir-action@develop env: REPO: self From 9ac24e95868a7fd747aea3a8ae187b9fc62a0b97 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 15:26:49 +0200 Subject: [PATCH 10/13] include build within test --- .github/workflows/test_and_build.yml | 41 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 7020468..4315bfe 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -36,24 +36,29 @@ jobs: - name: Tests run: cd integration_test && bundle install && bundle exec rake test - run: cd klarna-payments-backend && bundle install - build: - needs: test - runs-on: "ubuntu-20.04" - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v4 - with: - node-version: "12" - cache: "npm" - - name: Install and build with verbose logging + - name: Setup Git for publishing + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + - name: Create and switch to build branch + run: | + echo "Checking if build branch exists..." + git fetch origin build:build || echo "Build branch doesn't exist yet, will create it" + git checkout -B build + - name: Clear build branch and copy dist contents + run: | + echo "Clearing current build branch contents..." + git rm -rf . || echo "No files to remove" + echo "Copying dist contents to root..." + cp -r dist/* . || echo "No files in dist to copy" + ls -la + - name: Commit and push to build branch run: | - echo "Starting npm install..." - npm install --verbose - echo "Starting npm build..." - npm run build --verbose - - uses: s0/git-publish-subdir-action@develop + echo "Adding files to git..." + git add . + echo "Committing changes..." + git commit -m "Build from commit ${{ github.sha }}" || echo "No changes to commit" + echo "Pushing to build branch..." + git push origin build env: - REPO: self - BRANCH: build - FOLDER: dist GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e8c36be274e99d33cace3e044a446546140bfea7 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 15:36:05 +0200 Subject: [PATCH 11/13] use force push --- .github/workflows/test_and_build.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 4315bfe..051b255 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -45,20 +45,18 @@ jobs: echo "Checking if build branch exists..." git fetch origin build:build || echo "Build branch doesn't exist yet, will create it" git checkout -B build - - name: Clear build branch and copy dist contents + - name: Clean working directory except .git and dist run: | - echo "Clearing current build branch contents..." - git rm -rf . || echo "No files to remove" - echo "Copying dist contents to root..." - cp -r dist/* . || echo "No files in dist to copy" - ls -la + find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'dist' -exec rm -rf {} + + cp -r dist/* . + rm -rf dist - name: Commit and push to build branch run: | echo "Adding files to git..." git add . echo "Committing changes..." git commit -m "Build from commit ${{ github.sha }}" || echo "No changes to commit" - echo "Pushing to build branch..." - git push origin build + echo "Pushing to build branch (force)..." + git push origin build --force env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4ea99813242cce0d32c962a701fd1eb3990d6dd0 Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 15:49:01 +0200 Subject: [PATCH 12/13] return back to git-publish-subdir-action --- .github/workflows/test_and_build.yml | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index 051b255..d832407 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -36,27 +36,10 @@ jobs: - name: Tests run: cd integration_test && bundle install && bundle exec rake test - run: cd klarna-payments-backend && bundle install - - name: Setup Git for publishing - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - name: Create and switch to build branch - run: | - echo "Checking if build branch exists..." - git fetch origin build:build || echo "Build branch doesn't exist yet, will create it" - git checkout -B build - - name: Clean working directory except .git and dist - run: | - find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'dist' -exec rm -rf {} + - cp -r dist/* . - rm -rf dist - - name: Commit and push to build branch - run: | - echo "Adding files to git..." - git add . - echo "Committing changes..." - git commit -m "Build from commit ${{ github.sha }}" || echo "No changes to commit" - echo "Pushing to build branch (force)..." - git push origin build --force + + - uses: s0/git-publish-subdir-action@develop env: + REPO: self + BRANCH: build + FOLDER: dist GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ef1955dbdd36386f2162bcbf646fa424931e3bbc Mon Sep 17 00:00:00 2001 From: Rimon Shenouda Date: Thu, 17 Jul 2025 16:17:45 +0200 Subject: [PATCH 13/13] update release workflow for more debugging --- .github/workflows/release.yml | 28 +++++++++++++++++++++------- .github/workflows/test_and_build.yml | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cdc440..5a4487d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,16 +6,28 @@ jobs: release: runs-on: "ubuntu-22.04" steps: - - uses: actions/checkout@v2 + - name: Checkout build branch + uses: actions/checkout@v3 with: ref: build - - run: |1 + + - name: Configure Git + run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - - run: git fetch - - run: git checkout release - - run: git merge -X theirs build --allow-unrelated-histories - - run: git push origin release + + - name: Fetch all branches + run: git fetch + + - name: Checkout release branch + run: git checkout release + + - name: Merge build into release + run: git merge -X theirs build --allow-unrelated-histories + + - name: Push to release + run: git push origin release + - name: Create Release id: create_release uses: zendesk/action-create-release@v1 @@ -23,4 +35,6 @@ jobs: tag_schema: semantic env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: echo "Released ${{steps.create_release.outputs.current_tag}}" + + - name: Output Tag + run: echo "Released ${{ steps.create_release.outputs.current_tag }}" diff --git a/.github/workflows/test_and_build.yml b/.github/workflows/test_and_build.yml index d832407..e2446fc 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -3,7 +3,7 @@ name: Test and Build on: [push] jobs: - test: + test_build: runs-on: "ubuntu-22.04" env: RACK_ENV: test