chore(js): use bun instead of yarn

This commit is contained in:
Paul Chavard 2024-03-13 11:06:24 +01:00
parent 3f54d46f19
commit 94ecd2166e
17 changed files with 68 additions and 9033 deletions

View file

@ -11,7 +11,7 @@ runs:
using: composite
steps:
- name: Save test reports
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ inputs.results_path }}
key: tests-reports-${{ github.ref }}-${{ github.sha }}-${{ github.run_id }}

View file

@ -5,7 +5,7 @@ runs:
using: composite
steps:
- name: Assets cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
public/assets
@ -20,7 +20,5 @@ runs:
- name: Precompile assets
env:
RAILS_ENV: test
run: |
rm bin/yarn
bin/rails assets:precompile --trace
run: bin/rails assets:precompile --trace
shell: bash

View file

@ -16,19 +16,17 @@ runs:
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
- name: Install yarn
run: |
npm install --global yarn
shell: bash
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Install Node modules
run: |
node --version
yarn install --frozen-lockfile
bun --version
bun install
shell: bash
- name: Setup environment variables

View file

@ -31,7 +31,7 @@ runs:
#
# The actual retrieval uses the `restore-keys` instead.
- name: Restore previous runs timings
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ inputs.results_path }}
key: single-instance-report-${{ github.sha }}-${{ env.dummy_random_value }}

View file

@ -21,7 +21,7 @@ jobs:
ports: [ "5432:5432" ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup the app code and dependancies
uses: ./.github/actions/ci-setup-rails
@ -36,22 +36,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
cache: 'yarn'
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- name: Install Node modules
run: |
node --version
yarn install --frozen-lockfile
bun --version
bun install
shell: bash
- name: Run tests
run: |
yarn test
bun run test
unit_tests:
name: Unit tests
@ -72,7 +73,7 @@ jobs:
instances: [0, 1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install build dependancies
# - fonts pickable by ImageMagick
@ -97,9 +98,9 @@ jobs:
bin/rspec $SPEC_FILES --format progress --format RspecJunitFormatter --out tmp/rspec_${{ github.job }}_${{ strategy.job-index }}.junit.xml
- name: Upload test results for this instance
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
name: rspec-results-${{ github.job }}-${{ strategy.job-index }}
path: tmp/rspec_${{ github.job }}_${{ strategy.job-index }}.junit.xml
system_tests:
@ -121,7 +122,7 @@ jobs:
instances: [0, 1]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup the app runtime and dependencies
uses: ./.github/actions/ci-setup-rails
@ -141,9 +142,9 @@ jobs:
RAILS_ENV=test bin/rspec $SPEC_FILES --format progress --format RspecJunitFormatter --out tmp/rspec_${{ github.job }}_${{ strategy.job-index }}.junit.xml
- name: Upload test results for this instance
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports
name: rspec-results-${{ github.job }}-${{ strategy.job-index }}
path: tmp/rspec_${{ github.job }}_${{ strategy.job-index }}.junit.xml
save_test_reports:
@ -152,13 +153,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Collect test results from all instances
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: test-reports
path: tmp
pattern: rspec-results-*
merge-multiple: true
- name: Save test results and timing data, to better split future tests
uses: ./.github/actions/ci-save-split-tests

View file

@ -38,11 +38,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@ -67,4 +67,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3

View file

@ -7,6 +7,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Block Fixup Commit Merge
uses: 13rac1/block-fixup-merge-action@v2.0.0

View file

@ -18,7 +18,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2 # Fetch the last 2 commits to be able to compare with the base branch

View file

@ -41,7 +41,7 @@ Pour faire tourner sidekiq, vous aurez besoin de :
#### Développement
- rbenv : voir https://github.com/rbenv/rbenv-installer#rbenv-installer--doctor-scripts
- Yarn : voir https://yarnpkg.com/en/docs/install
- Bun : voir https://bun.sh/docs/installation
#### Tests

View file

@ -19,10 +19,21 @@ FileUtils.chdir APP_ROOT do
# Install JavaScript dependencies
system! 'node --version'
system! 'bin/yarn install'
system! 'bun --version'
system! 'bun install'
puts "\n== Updating webdrivers =="
system! 'RAILS_ENV=test bin/rails webdrivers:chromedriver:update'
if ENV["UPDATE_WEBDRIVER"]
puts "\n== Updating webdrivers =="
puts "\nyou must add ~/.local/bin to your path"
system! 'bunx @puppeteer/browsers clear --path ~/.local/bin/headless_browsers'
system! 'bunx @puppeteer/browsers install chromedriver --path ~/.local/bin/headless_browsers'
system! 'bunx @puppeteer/browsers install chrome --path ~/.local/bin/headless_browsers'
puts "\n if chrome and chromedriver versions are not compatible, add the version you want in the above lines. ex : chrome@121"
system! 'rm -f ~/.local/bin/chromedriver && ln -s $(find ~/.local/bin/headless_browsers -type f -name chromedriver) ~/.local/bin/chromedriver'
system! 'rm -f ~/.local/bin/chrome && ln -s $(find ~/.local/bin/headless_browsers -type f -name chrome) ~/.local/bin/chrome'
end
puts "\n== Copying sample files =="
unless File.exist?('.env')

View file

@ -16,16 +16,16 @@ FileUtils.chdir APP_ROOT do
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
system! 'node --version'
system! 'bin/yarn install'
system! 'bin/yarn clean'
system! 'bun --version'
system! 'bun install'
if ENV["UPDATE_WEBDRIVER"]
puts "\n== Updating webdrivers =="
puts "\nyou must add ~/.local/bin to your path"
system! 'npx @puppeteer/browsers clear --path ~/.local/bin/headless_browsers'
system! 'bunx @puppeteer/browsers clear --path ~/.local/bin/headless_browsers'
system! 'npx @puppeteer/browsers install chromedriver --path ~/.local/bin/headless_browsers'
system! 'npx @puppeteer/browsers install chrome --path ~/.local/bin/headless_browsers'
system! 'bunx @puppeteer/browsers install chromedriver --path ~/.local/bin/headless_browsers'
system! 'bunx @puppeteer/browsers install chrome --path ~/.local/bin/headless_browsers'
puts "\n if chrome and chromedriver versions are not compatible, add the version you want in the above lines. ex : chrome@121"
system! 'rm -f ~/.local/bin/chromedriver && ln -s $(find ~/.local/bin/headless_browsers -type f -name chromedriver) ~/.local/bin/chromedriver'

View file

@ -1,17 +0,0 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
select { |dir| File.expand_path(dir) != __dir__ }.
product(["yarn", "yarn.cmd", "yarn.ps1"]).
map { |dir, file| File.expand_path(file, dir) }.
find { |file| File.executable?(file) }
if yarn
exec yarn, *ARGV
else
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end

BIN
bun.lockb Executable file

Binary file not shown.

View file

@ -11,7 +11,7 @@ Usually, a deployment goes like this (in pseudo-code):
# For each server:
# Stop the server
# Get the new code (e.g. `git clone git@github.com:betagouv/demarches-simplifiees.fr.git`)
# Install new dependencies (e.g. `bundle install && yarn install`)
# Install new dependencies (e.g. `bundle install && bun install`)
# Restart the app server
# Run data migrations (e.g. `rake after_party:run`)
```

View file

@ -6,6 +6,6 @@ task :lint do
sh "bundle exec i18n-tasks unused --locale en" # TODO: check for all locales
sh "bundle exec i18n-tasks check-consistent-interpolations"
sh "bundle exec brakeman --no-pager"
sh "yarn lint:js"
sh "yarn lint:types"
sh "bun lint:js"
sh "bun lint:types"
end

View file

@ -75,6 +75,12 @@
"zod": "^3.20.2"
},
"devDependencies": {
"@esbuild/darwin-arm64": "=0.19.9",
"@esbuild/linux-x64": "=0.19.9",
"@esbuild/win32-x64": "=0.19.9",
"@rollup/rollup-linux-x64-gnu": "=4.9.1",
"@rollup/rollup-darwin-arm64": "=4.9.1",
"@rollup/rollup-win32-x64-msvc": "=4.9.1",
"@types/debounce": "^1.2.1",
"@types/geojson": "^7946.0.10",
"@types/is-hotkey": "^0.1.7",
@ -121,5 +127,10 @@
"resolutions": {
"string-width": "4.2.2",
"wrap-ansi": "7.0.0"
}
},
"trustedDependencies": [
"core-js",
"esbuild",
"rollup"
]
}

8968
yarn.lock

File diff suppressed because it is too large Load diff