From b680d9f868b422901be02adc3eb812c42d3db11f Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 26 Apr 2024 16:14:56 +0200 Subject: [PATCH 1/3] fix(test): Reload picture after description changed Make sure the picture is reloaded from that database in order to catch changes. --- spec/features/admin/picture_library_integration_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/picture_library_integration_spec.rb b/spec/features/admin/picture_library_integration_spec.rb index ba8b0c90b2..13b692cbbf 100644 --- a/spec/features/admin/picture_library_integration_spec.rb +++ b/spec/features/admin/picture_library_integration_spec.rb @@ -76,7 +76,7 @@ within "#flash_notices" do expect(page).to have_content("Picture updated successfully") end - expect(picture.description_for(language)).to eq("This is an amazing image.") + expect(picture.reload.description_for(language)).to eq("This is an amazing image.") end scenario "allows to add multi language picture descriptions", :js do @@ -90,7 +90,7 @@ within "#flash_notices" do expect(page).to have_content("Picture updated successfully") end - expect(picture.description_for(german)).to eq("Tolles Bild.") + expect(picture.reload.description_for(german)).to eq("Tolles Bild.") end end end From 079cb43adfe9fb6437346aa8eff4fc68882fbf47 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 26 Apr 2024 18:21:13 +0200 Subject: [PATCH 2/3] CI: Use build javascript artifact for testing We want to test if a changed JS dependency breaks our feature specs. --- .github/workflows/build_test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 1fda583435..b8833b527e 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -51,6 +51,10 @@ jobs: run: yarn install - name: YARN build run: yarn build + - uses: actions/upload-artifact@v4 + with: + name: javascript-files-${{ github.ref_name }} + path: vendor/javascript RSpec: needs: [check_yarn_lock, build_javascript] @@ -135,6 +139,11 @@ jobs: sudo apt update -qq sudo apt install -qq --fix-missing libmysqlclient-dev -o dir::cache::archives="/home/runner/apt/cache" sudo chown -R runner /home/runner/apt/cache + - uses: actions/download-artifact@v4 + if: needs.check_yarn_lock.outputs.yarn_lock_changed == 'true' + with: + name: javascript-files-${{ github.ref_name }} + path: vendor/javascript - name: Prepare database run: | bundle exec rake alchemy:spec:prepare From 7a46e57965bd2e368c80e89228abca4c66383876 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 26 Apr 2024 21:59:58 +0200 Subject: [PATCH 3/3] CI: Commit changes to javascript bundles If a dependency has been updated we rebuild the bundles. After the tests have passed we commit the changes and skip gh actions for this commit. --- .github/workflows/build_test.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index b8833b527e..c9c7813016 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -58,7 +58,7 @@ jobs: RSpec: needs: [check_yarn_lock, build_javascript] - if: ${{ success('check_yarn_lock') && !failure('build_javascript')}} + if: ${{ success('check_yarn_lock') && !failure('build_javascript') }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -162,6 +162,36 @@ jobs: name: Screenshots path: spec/dummy/tmp/screenshots + PushJavascript: + runs-on: ubuntu-latest + needs: [check_yarn_lock, RSpec] + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of our personal access token. + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - uses: actions/download-artifact@v4 + if: needs.check_yarn_lock.outputs.yarn_lock_changed == 'true' + with: + name: javascript-files-${{ github.ref_name }} + path: vendor/javascript + - name: Check git status + id: git-status + run: git diff --quiet vendor/javascript || echo "changed=true" >> $GITHUB_OUTPUT + - name: git commit + if: steps.git-status.outputs.changed == 'true' + run: | + git config --local user.name 'AlchemyCMS - CI Bot' + git config --local user.email 'alchemy@blish.cloud' + git add vendor/javascript + git commit -m "Update JS packages" -m "Rebuilt packages after updating dependencies." --trailer "skip-checks: true" + - name: Push changes + if: steps.git-status.outputs.changed == 'true' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.ALCHEMY_CI_BOT_ACCESS_TOKEN }} + branch: ${{ github.ref }} + Jest: runs-on: ubuntu-latest env: