Skip to content

Commit

Permalink
Merge branch 'main' into fxvpn-32-in-app-message
Browse files Browse the repository at this point in the history
  • Loading branch information
mcleinman committed Dec 2, 2024
2 parents 22d3fec + 0705a13 commit 3f34248
Show file tree
Hide file tree
Showing 176 changed files with 19,195 additions and 34,227 deletions.
110 changes: 110 additions & 0 deletions .github/l10n/check_l10n_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,121 @@
import xml.etree.ElementTree as etree
import json
import os
import subprocess
import sys
import tempfile

script_folder = os.path.abspath(os.path.dirname(__file__))
vpn_root_folder = os.path.realpath(os.path.join(script_folder, os.pardir, os.pardir))

def fileContentsAsJSON(filepath):
try:
with open(filepath, 'r') as file:
content = json.load(file)

if not content:
print(f"No content found in: {filepath}")
sys.exit(1)
return content
except FileNotFoundError:
print(f"File not found: {filepath}")
sys.exit(1)
except Exception as e:
print(f"An error occurred while loading {filepath}: {e}")
sys.exit(1)

# Check if it uses shared strings. If so, pull the value for “title”, “subtitle”, then look within "blocks"
def getSharedStringsInManifest(mainifest_contents):
shared_string_ids = []
# If it includes the key “message” and if within "message", there is a “usesSharedStrings” key that is true...
if manifest_contents.get("message", {}).get("usesSharedStrings", False):
#...collect all the string IDs
if "title" in manifest_contents["message"]:
shared_string_ids.append(manifest_contents["message"]["title"])
else:
print(f"No title found for: {addon}")
sys.exit(1)
if "subtitle" in manifest_contents["message"]:
# It is acceptable if there is no subtitle (but title is required)
shared_string_ids.append(manifest_contents["message"]["subtitle"])
if not "blocks" in manifest_contents["message"]:
print(f"No blocks found for: {addon}")
sys.exit(1)
for block in manifest_contents["message"]["blocks"]:
if not "content" in block:
print(f"No content found in {addon} for {block}")
sys.exit(1)
if isinstance(block["content"], str):
shared_string_ids.append(block["content"])
elif isinstance(block["content"], list):
# This is the contents of a bulleted or ordered list; go one layer deeper.
for list_item in block["content"]:
if isinstance(list_item["content"], str):
shared_string_ids.append(list_item["content"])
else:
print(f"No content found in {addon} for {list_item}")
sys.exit(1)
else:
print(f"Content found in {addon} was unknown type for {block}")
sys.exit(1)
return shared_string_ids

### 1. Check Addons' shared strings - all string IDs should be present in the translation file. ###
# Find list of all addon folders
addon_path = os.path.join(vpn_root_folder, "addons")
try:
addon_list = [item for item in os.listdir(addon_path) if os.path.isdir(os.path.join(addon_path, item))]
except FileNotFoundError:
print(f"Path not found: {addon_path}")
sys.exit(1)
except Exception as e:
print(f"An error occurred when finding all addons: {e}")
sys.exit(1)

if len(addon_list) == 0:
print(f"No addons found")
sys.exit(1)

shared_string_ids = []

# For each, open the manifest file and pull out the shared strings
for addon in addon_list:
manifest_path = os.path.join(addon_path, addon, "manifest.json")
manifest_contents = fileContentsAsJSON(manifest_path)
shared_string_ids = shared_string_ids + getSharedStringsInManifest(manifest_contents)

# Create temporary translation file
tmp_path = tempfile.mkdtemp()
shared_addon_strings = os.path.join(addon_path, "strings.yaml")
shared_addons_tmp_file = os.path.join(tmp_path, "strings.xliff")
generate_addon_python_file = os.path.join(vpn_root_folder, "scripts", "utils", "generate_shared_addon_xliff.py")
p = subprocess.run(['python', generate_addon_python_file, '-i', shared_addon_strings, '-o', shared_addons_tmp_file])

# Check that the shared strings are present in the translation file
if not os.path.isfile(shared_addons_tmp_file):
print(f"Unable to find {shared_addons_tmp_file}")
sys.exit(1)
try:
with open(shared_addons_tmp_file, 'r') as file:
shared_string_content = file.read()
if not shared_string_content:
print(f"No content found in: {shared_addons_tmp_file}")
sys.exit(1)
except FileNotFoundError:
print(f"File not found: {shared_addons_tmp_file}")
sys.exit(1)
except Exception as e:
print(f"An error occurred while loading {shared_addons_tmp_file}: {e}")
sys.exit(1)

for shared_string_id in shared_string_ids:
string_id_unit = "<trans-unit id=\"" + shared_string_id + "\">"
if string_id_unit not in shared_string_content:
print(f"{string_id_unit} not found in shared string file")
sys.exit(1)

### 2. Check all strings for overall issues. ###

# Paths are relative to the root folder
paths = [
"translations.ts",
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/auth_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ jobs:
- name: Running tests
shell: bash
working-directory: ./build/tests/auth_tests
run: |
ctest --output-on-failure
run: ctest -L auth --output-on-failure

macos-unit-tests:
runs-on: macos-latest
Expand Down Expand Up @@ -78,9 +76,7 @@ jobs:
cmake --build build/cmake --target app_auth_tests
- name: Running tests
working-directory: ./build/cmake/tests/auth_tests
run: |
ctest --output-on-failure
run: ctest -L auth --output-on-failure

windows-unit-tests:
name: Run auth tests on Windows
Expand Down Expand Up @@ -118,6 +114,4 @@ jobs:
- name: Running tests
shell: bash
working-directory: ./build/tests/auth_tests
run: |
ctest --output-on-failure
run: ctest -L auth --output-on-failure
44 changes: 44 additions & 0 deletions .github/workflows/build_addons.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# A reusable workflow to build addons
on:
workflow_call:
inputs:
test-addons-name:
required: true
type: string

jobs:
build-test-addons:
name: Build Test Addons
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Setup addons cache
id: addons-cache
uses: actions/cache@v4
with:
path: build-addons/
key: test-addons-${{ hashFiles('addons/', 'test/functional/addons/') }}

- name: Install build dependencies
if: steps.addons-cache.outputs.cache-hit != 'true'
shell: bash
run: |
git submodule init
git submodule update 3rdparty/i18n
sudo apt-get update
sudo apt-get install -y $(./scripts/linux/getdeps.py -b linux/debian/control)
- name: Build test addons
if: steps.addons-cache.outputs.cache-hit != 'true'
shell: bash
run: |
mkdir -p build-addons/
cmake -S $(pwd)/tests/functional/addons -B build-addons/
cmake --build build-addons/
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test-addons-name }}
path: build-addons/
2 changes: 1 addition & 1 deletion .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
with:
bundle: mozillavpn.flatpak
manifest-path: manifest/org.mozilla.vpn.yml
cache-key: flatpak-builder-${{ github.sha }}
cache-key: flatpak-builder-${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.sha }}

dependabot-cargo:
name: "Update Crates"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linters (clang, l10n)
name: Linters (clang, l10n, colors)
on:
# Triggers the workflow on pull request events but only for the main branch
pull_request:
Expand All @@ -12,7 +12,7 @@ on:

jobs:
linter:
name: Run Main Linters (clang, l10n, etc.)
name: Run Main Linters (clang, l10n, colors, etc.)
runs-on: ubuntu-22.04
steps:
- name: Clone repository
Expand Down Expand Up @@ -65,6 +65,10 @@ jobs:
run: |
scripts/ci/check_lang_names.py
- name: Check for proper color usage
run: |
scripts/ci/check_colors.py nebula/ui/themes/
ktlint:
name: Run ktLint
runs-on: ubuntu-latest
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
jobs:
source-bundle:
name: Source Bundle
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -35,9 +35,7 @@ jobs:
- name: Build source bundle
shell: bash
env:
GITREF: ${{github.ref}}
run: ./scripts/linux/script.sh --source --gitref ${GITREF}
run: ./scripts/linux/script.sh --source --gitref ${{github.ref}}

- name: Upload source bundle
uses: actions/upload-artifact@v4
Expand All @@ -51,7 +49,7 @@ jobs:
needs: source-bundle
runs-on: ubuntu-latest
container:
image: fedora:40
image: fedora:41

steps:
- name: Download Source Package
Expand Down
Loading

0 comments on commit 3f34248

Please sign in to comment.