From a3b19875ec1e23fd592edf9b1768fe116b020f8a Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 22 Mar 2026 15:58:25 +0100 Subject: [PATCH 1/2] Implement Node.js caching in the GitHub Actions workflows The `setup-node` action contains built-in support for caching [1], so this commit makes sure we use it for all Node.js-based workflows to reduce workflow execution time. Note that, contrary what one might expect [2], the `node_modules` directory is deliberately not cached because it can conflict with differing Node.js versions and because it's not useful in combination with `npm ci` usage which wipes the `node_modules` folder unconditionally. Therefore, the action instead caches the global `npm` cache directory instead which does not suffer from these problems and still provides a speed-up at installation time. [1] https://github.com/actions/setup-node?tab=readme-ov-file#caching-global-packages-data [2] https://github.com/actions/setup-node/issues/416 [3] https://github.com/actions/cache/issues/67 --- .github/workflows/ci.yml | 1 + .github/workflows/coverage.yml | 1 + .github/workflows/font_tests.yml | 1 + .github/workflows/lint.yml | 1 + .github/workflows/prefs_tests.yml | 1 + .github/workflows/publish_release.yml | 1 + .github/workflows/publish_website.yml | 1 + .github/workflows/types_tests.yml | 1 + .github/workflows/update_locales.yml | 1 + 9 files changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b5c4a796..fa70d5d83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 94d36ed7f..0650efe03 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,6 +25,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/font_tests.yml b/.github/workflows/font_tests.yml index 1dcecb6e9..6ff7aecde 100644 --- a/.github/workflows/font_tests.yml +++ b/.github/workflows/font_tests.yml @@ -46,6 +46,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0fb706004..c9ec2cb58 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,6 +24,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/prefs_tests.yml b/.github/workflows/prefs_tests.yml index fb8c91e91..96c8c9784 100644 --- a/.github/workflows/prefs_tests.yml +++ b/.github/workflows/prefs_tests.yml @@ -24,6 +24,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 5fe18a329..b9dd3e9ff 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -26,6 +26,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' registry-url: 'https://registry.npmjs.org' - name: Install dependencies diff --git a/.github/workflows/publish_website.yml b/.github/workflows/publish_website.yml index f8d12822a..b55d86679 100644 --- a/.github/workflows/publish_website.yml +++ b/.github/workflows/publish_website.yml @@ -26,6 +26,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/types_tests.yml b/.github/workflows/types_tests.yml index 9d08a0e05..30d565817 100644 --- a/.github/workflows/types_tests.yml +++ b/.github/workflows/types_tests.yml @@ -24,6 +24,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: ${{ matrix.node-version }} + cache: 'npm' - name: Install dependencies run: npm ci diff --git a/.github/workflows/update_locales.yml b/.github/workflows/update_locales.yml index 49718b679..18ca96bfc 100644 --- a/.github/workflows/update_locales.yml +++ b/.github/workflows/update_locales.yml @@ -24,6 +24,7 @@ jobs: uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: lts/* + cache: 'npm' - name: Install dependencies run: npm ci From 8d4151cfbb76758b1be339cb25187863a0c23465 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 22 Mar 2026 16:37:59 +0100 Subject: [PATCH 2/2] Fix Python caching in the GitHub Actions workflows For the Python-based workflows we were already using `pip` caching [1], but sadly this isn't fully functional at the moment because the caching functionality uses `requirements.txt` to determine when to create or invalidate the cache. However, we have two different `pip` install commands but only a `requirements.txt` for one of them (the Fluent linter), which means that the other job (the font tests) will not populate the cache with its dependencies. This can be seen by opening any font tests or Fluent linting build and noticing that they report the exact same cache key even though their dependencies are different. In the installation step the dependencies are reported as "Downloading [package].whl" instead of the expected "Using cached [package].whl". This commit fixes the issue by explicitly defining a `requirements.txt` file for both jobs and pointing the caching functionality to the specific file paths to make sure that unique caches with the correct package data are used. While we're here we also align the syntax and step titles in the files for consistency. [1] https://github.com/actions/setup-python?tab=readme-ov-file#caching-packages-dependencies --- .../{requirements.txt => fluent_linter_requirements.txt} | 0 .github/font_tests_requirements.txt | 1 + .github/workflows/fluent_linter.yml | 9 ++++----- .github/workflows/font_tests.yml | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) rename .github/{requirements.txt => fluent_linter_requirements.txt} (100%) create mode 100644 .github/font_tests_requirements.txt diff --git a/.github/requirements.txt b/.github/fluent_linter_requirements.txt similarity index 100% rename from .github/requirements.txt rename to .github/fluent_linter_requirements.txt diff --git a/.github/font_tests_requirements.txt b/.github/font_tests_requirements.txt new file mode 100644 index 000000000..e8ce6dfc4 --- /dev/null +++ b/.github/font_tests_requirements.txt @@ -0,0 +1 @@ +fonttools==4.* diff --git a/.github/workflows/fluent_linter.yml b/.github/workflows/fluent_linter.yml index f92d1df03..e7dfbca34 100644 --- a/.github/workflows/fluent_linter.yml +++ b/.github/workflows/fluent_linter.yml @@ -34,11 +34,10 @@ jobs: with: python-version: '3.14' cache: 'pip' + cache-dependency-path: '.github/fluent_linter_requirements.txt' - - name: Install Fluent dependencies - run: | - pip install -r .github/requirements.txt + - name: Install requirements + run: pip install -r .github/fluent_linter_requirements.txt - name: Lint Fluent reference files - run: | - moz-fluent-lint ./l10n/en-US --config .github/fluent_linter_config.yml + run: moz-fluent-lint ./l10n/en-US --config .github/fluent_linter_config.yml diff --git a/.github/workflows/font_tests.yml b/.github/workflows/font_tests.yml index 6ff7aecde..e8630d330 100644 --- a/.github/workflows/font_tests.yml +++ b/.github/workflows/font_tests.yml @@ -56,9 +56,10 @@ jobs: with: python-version: '3.14' cache: 'pip' + cache-dependency-path: '.github/font_tests_requirements.txt' - - name: Install Fonttools - run: pip install fonttools + - name: Install requirements + run: pip install -r .github/font_tests_requirements.txt - name: Run font tests run: npx gulp fonttest --headless