Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/fluent/linter_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# See https://github.com/mozilla-l10n/moz-fluent-linter/blob/main/src/fluent_linter/config.yml
# for details

---
# Check brand names
CO01:
enabled: true
brands:
- Firefox
- Mozilla
- Profiler
exclusions:
files: []
messages: []
# Enforce variable comments
VC:
disabled: false
# Enforce placeholder style, e.g. { $variable }
PS01:
disabled: false
1 change: 1 addition & 0 deletions .github/fluent/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
moz-fluent-linter~=0.4.9
35 changes: 35 additions & 0 deletions .github/workflows/fluent_linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint Reference Files
on:
push:
paths:
- 'locales/en-US/*.ftl'
- '.github/workflows/fluent_linter.yml'
- '.github/fluent/*'
branches:
- main
pull_request:
paths:
- 'locales/en-US/*.ftl'
- '.github/workflows/fluent_linter.yml'
- '.github/fluent/*'
branches:
- main
workflow_dispatch:
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v5
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
Comment on lines +24 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand reading this, cache: pip won't work as expected for us here because the requirements.txt file is not in the root directory. You need to specify cache-dependency-path also to make sure that it caches it correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input cache-dependency-path is used for cases when multiple dependency files are used, they are located in different subdirectories or different files for the hash that want to be used.

We only use one requirement file, unless I missed some Python used elsewhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that this was used when multiple dependency files are present or they are located in different subdirectories. So to be able to cache, the dependency file has to be in the root directly. Otherwise you need to specify the location since it doesn't look for the sub directories by default.

I also see that you can use pip-install: -r requirements.txt here, but I don't know what benefits it adds. Probably not a huge deal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah see another text here:

Action will try to search dependencies files (requirements.txt for pip and Pipfile.lock for pipenv) in the repository root (or relative to the repository root, if patterns are used) and throw error if no one is found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action will try to search dependencies files (requirements.txt for pip and Pipfile.lock for pipenv) in the repository root (or relative to the repository root, if patterns are used) and throw error if no one is found.

That is why I had to create a requirements.txt file. Installing directly from pip broke the workflow
2b7b8a0

cache-dependency-path: '.github/fluent/requirements.txt'
- name: Install Python dependencies
run: |
pip install -r .github/fluent/requirements.txt
- name: Lint reference
run: |
moz-fluent-lint ./locales/en-US --config .github/fluent/linter_config.yml