From a517e46ae1898b6fb570d1fda976d5218144857d Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 7 Feb 2025 08:48:32 -0800 Subject: [PATCH 1/8] chore(ci): add a workflow for linting GitHub Actions workflow files --- .github/workflows/lint.yaml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index de6b3f0..9ce824e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,5 +1,5 @@ --- -name: Run ESLint +name: Run Linters on: pull_request: @@ -12,7 +12,7 @@ on: - v*.* jobs: - build: + eslint: runs-on: ubuntu-latest name: Run ESLint steps: @@ -26,3 +26,21 @@ jobs: - name: Run ESLint run: | ./bin/host_eslint.sh + + actionlint: + runs-on: ubuntu-latest + name: Run Actionlint + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download and run actionlint + run: | + ACTIONLINT_VERSION="1.7.7" + ACTIONLINT_FILE="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" + ACTIONLINT_URL="https://github.com/rhysd/actionlint/releases/download" + ACTIONLINT_DOWNLOAD_URL="$ACTIONLINT_URL/v$ACTIONLINT_VERSION/$ACTIONLINT_FILE" + curl -L -o actionlint.tar.gz "$ACTIONLINT_DOWNLOAD_URL" + tar xzf actionlint.tar.gz + + ./actionlint From 3a464dc654d6cd9ba8d720d5185e13c135207c11 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 7 Feb 2025 08:57:26 -0800 Subject: [PATCH 2/8] chore(ci): refactor the worklow linter pipeline --- .github/workflows/lint.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 9ce824e..5bbd52c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -29,18 +29,21 @@ jobs: actionlint: runs-on: ubuntu-latest - name: Run Actionlint + name: Run Linter for GitHub Actions Workflows + strategy: + matrix: + actionlint-version: ['1.7.7'] steps: - name: Checkout uses: actions/checkout@v4 - - name: Download and run actionlint + - name: Download actionlint run: | - ACTIONLINT_VERSION="1.7.7" - ACTIONLINT_FILE="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" + ACTIONLINT_FILE="actionlint_${{ matrix.actionlint-version }}_linux_amd64.tar.gz" ACTIONLINT_URL="https://github.com/rhysd/actionlint/releases/download" - ACTIONLINT_DOWNLOAD_URL="$ACTIONLINT_URL/v$ACTIONLINT_VERSION/$ACTIONLINT_FILE" + ACTIONLINT_DOWNLOAD_URL="$ACTIONLINT_URL/v${{ matrix.actionlint-version }}/$ACTIONLINT_FILE" curl -L -o actionlint.tar.gz "$ACTIONLINT_DOWNLOAD_URL" tar xzf actionlint.tar.gz - ./actionlint + - name: Run actionlint + run: ./actionlint From f229a61f48ab9345cf3708fdd1883cdc464255f8 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 7 Feb 2025 09:01:58 -0800 Subject: [PATCH 3/8] chore(ci): resolve `actionlint` issues --- .github/workflows/build.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ba7ed22..18887b2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -33,9 +33,7 @@ jobs: export SCREENLY_CE_VERSION="0.0.0" fi - cat src/manifest-${{ matrix.platform }}.json \ - | jq --arg version "$SCREENLY_CE_VERSION" '.version = $version' \ - > src/manifest.json + jq --arg version "$SCREENLY_CE_VERSION" '.version = $version' src/manifest-${{ matrix.platform }}.json > src/manifest.json - name: Build Docker images run: | @@ -45,7 +43,7 @@ jobs: run: | docker run \ --rm \ - -v $(pwd):/app:delegated \ + -v "$(pwd):/app:delegated" \ -v /app/node_modules \ sce_webpack:latest \ /bin/bash -c "npx webpack --config webpack.dev.js && npm run test" @@ -55,7 +53,7 @@ jobs: mkdir artifacts docker run \ --rm \ - -v $(pwd)/artifacts:/app/artifacts:delegated \ + -v "$(pwd)/artifacts:/app/artifacts:delegated" \ -v /app/artifacts/node_modules \ sce_webpack:latest \ /bin/bash -c "npm run build && cp -r dist/ artifacts/" From 585ce0a90d15476d226c166c314cb1ca8da3dcd9 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 7 Feb 2025 09:30:27 -0800 Subject: [PATCH 4/8] chore(ci): enable colored output when running `actionlint` --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5bbd52c..21f1de6 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -46,4 +46,4 @@ jobs: tar xzf actionlint.tar.gz - name: Run actionlint - run: ./actionlint + run: ./actionlint -color From 5d8ee052c8840addd8bc7a81e33372d9490880a2 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Sun, 9 Feb 2025 20:46:34 -0800 Subject: [PATCH 5/8] chore(ci): include linting in pre-commit checks --- README.md | 16 +++++++++++++++- bin/install_git_hooks.sh | 33 +++++++++++++++++++++++++++++++++ bin/run_actionlint.sh | 6 ++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 bin/install_git_hooks.sh create mode 100755 bin/run_actionlint.sh diff --git a/README.md b/README.md index 66a64a6..497fe4f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,20 @@ The extension is built using [webpack](https://webpack.js.org/). Please check our [contributing guidelines](CONTRIBUTING.md) for detailed information about opening pull requests and releasing new versions. +### Setup Git Hooks + +Before starting development, set up the Git hooks to ensure code quality: + +```bash +$ ./bin/install_git_hooks.sh +``` + +This will install pre-commit hooks that run: +* actionlint - Validates GitHub Actions workflow files +* ESLint - Checks JavaScript/TypeScript code quality + +### Development Mode + ```bash $ PLATFORM= \ VERSION= \ @@ -82,4 +96,4 @@ $ ./bin/run_tests.sh * Open Firefox and navigate to `about:debugging`. * Click on **This Firefox** and then **Load Temporary Add-on**. * You can either select the `manifest.json` file or the zipped extension. -* Find the extension URL and then open `moz-extension:///test/tests.html` in Firefox. \ No newline at end of file +* Find the extension URL and then open `moz-extension:///test/tests.html` in Firefox. diff --git a/bin/install_git_hooks.sh b/bin/install_git_hooks.sh new file mode 100755 index 0000000..b224838 --- /dev/null +++ b/bin/install_git_hooks.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +HOOK_DIR="$(git rev-parse --git-dir)/hooks" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Create pre-commit hook +cat > "${HOOK_DIR}/pre-commit" << 'EOF' +#!/bin/bash + +set -e + +# Get the root directory of the git repository +ROOT_DIR=$(git rev-parse --show-toplevel) + +# Run actionlint check +echo "Running actionlint check..." +"${ROOT_DIR}/bin/run_actionlint.sh" + +# Run eslint check +echo "Running eslint check..." +"${ROOT_DIR}/bin/run_eslint.sh" + +# If we got here, all checks passed +exit 0 +EOF + +# Make the hooks executable +chmod +x "${HOOK_DIR}/pre-commit" +chmod +x "${SCRIPT_DIR}/run_actionlint.sh" + +echo "Git hooks installed successfully!" diff --git a/bin/run_actionlint.sh b/bin/run_actionlint.sh new file mode 100755 index 0000000..e508a24 --- /dev/null +++ b/bin/run_actionlint.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -euo pipefail + +# Run actionlint on the workflows directory +docker run --rm -v $(pwd):/repo --workdir /repo rhysd/actionlint:latest -color From 3fc150d67fe776c2bdc63840fdd44b2d54f7d87d Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Sun, 9 Feb 2025 21:17:57 -0800 Subject: [PATCH 6/8] docs: add links to "actionlint" and "ESLint" --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 497fe4f..3330538 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ $ ./bin/install_git_hooks.sh ``` This will install pre-commit hooks that run: -* actionlint - Validates GitHub Actions workflow files -* ESLint - Checks JavaScript/TypeScript code quality +* [actionlint](https://github.com/rhysd/actionlint) - Validates GitHub Actions workflow files +* [ESLint](https://eslint.org/) - Checks JavaScript/TypeScript code quality ### Development Mode From beee8eaa68235765c8a7e48a4feb093595049d39 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Sun, 9 Feb 2025 21:33:58 -0800 Subject: [PATCH 7/8] chore(ci): make use of the Dockerized version of `actionlint` --- .github/workflows/lint.yaml | 10 +--------- bin/install_git_hooks.sh | 2 +- bin/run_actionlint.sh | 7 ++++++- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 21f1de6..e22506b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -37,13 +37,5 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Download actionlint - run: | - ACTIONLINT_FILE="actionlint_${{ matrix.actionlint-version }}_linux_amd64.tar.gz" - ACTIONLINT_URL="https://github.com/rhysd/actionlint/releases/download" - ACTIONLINT_DOWNLOAD_URL="$ACTIONLINT_URL/v${{ matrix.actionlint-version }}/$ACTIONLINT_FILE" - curl -L -o actionlint.tar.gz "$ACTIONLINT_DOWNLOAD_URL" - tar xzf actionlint.tar.gz - - name: Run actionlint - run: ./actionlint -color + run: ./bin/run_actionlint.sh diff --git a/bin/install_git_hooks.sh b/bin/install_git_hooks.sh index b224838..0c4977f 100755 --- a/bin/install_git_hooks.sh +++ b/bin/install_git_hooks.sh @@ -20,7 +20,7 @@ echo "Running actionlint check..." # Run eslint check echo "Running eslint check..." -"${ROOT_DIR}/bin/run_eslint.sh" +"${ROOT_DIR}/bin/host_eslint.sh" # If we got here, all checks passed exit 0 diff --git a/bin/run_actionlint.sh b/bin/run_actionlint.sh index e508a24..6fa8663 100755 --- a/bin/run_actionlint.sh +++ b/bin/run_actionlint.sh @@ -3,4 +3,9 @@ set -euo pipefail # Run actionlint on the workflows directory -docker run --rm -v $(pwd):/repo --workdir /repo rhysd/actionlint:latest -color +docker run \ + --rm \ + -v $(pwd):/repo \ + --workdir /repo \ + rhysd/actionlint:latest \ + -color From 655b696849cbde298092228d4a42fe37713bbfd3 Mon Sep 17 00:00:00 2001 From: nicomiguelino Date: Fri, 14 Feb 2025 10:00:08 -0800 Subject: [PATCH 8/8] fix: ci runtime errors --- .github/workflows/lint.yaml | 1 - bin/install_git_hooks.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2621583..bf58ab7 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -26,7 +26,6 @@ jobs: - name: Run ESLint run: | ./bin/run_eslint.sh src/ - ./bin/host_eslint.sh actionlint: runs-on: ubuntu-latest diff --git a/bin/install_git_hooks.sh b/bin/install_git_hooks.sh index 0c4977f..b224838 100755 --- a/bin/install_git_hooks.sh +++ b/bin/install_git_hooks.sh @@ -20,7 +20,7 @@ echo "Running actionlint check..." # Run eslint check echo "Running eslint check..." -"${ROOT_DIR}/bin/host_eslint.sh" +"${ROOT_DIR}/bin/run_eslint.sh" # If we got here, all checks passed exit 0