diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61a56b0..5a4487d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,19 +3,31 @@ name: Release on: [workflow_dispatch] jobs: - release: - runs-on: "ubuntu-20.04" + 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}}" \ No newline at end of file + + - 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 a8efd90..e2446fc 100644 --- a/.github/workflows/test_and_build.yml +++ b/.github/workflows/test_and_build.yml @@ -3,8 +3,8 @@ name: Test and Build on: [push] jobs: - test: - runs-on: "ubuntu-20.04" + test_build: + runs-on: "ubuntu-22.04" env: RACK_ENV: test PG_HOST: localhost @@ -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" @@ -23,32 +23,23 @@ 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 + - 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 - build: - needs: test - runs-on: "ubuntu-20.04" - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: "12" - cache: "npm" - - run: npm install && npm run build + - uses: s0/git-publish-subdir-action@develop env: 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..9b8caf3 100644 --- a/index.js +++ b/index.js @@ -20,29 +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 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 "# 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", @@ -53,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") 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 41fa2aa..d9325fa 100644 --- a/integration_test/Gemfile.lock +++ b/integration_test/Gemfile.lock @@ -1,16 +1,71 @@ GEM remote: https://rubygems.org/ + 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) 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 @@ -20,6 +75,7 @@ DEPENDENCIES minitest minitest-reporters rake + stock (~> 3.0.0)! BUNDLED WITH 2.2.27