diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2a939ac..13669ae 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 \ sbe_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 \ sbe_webpack:latest \ /bin/bash -c "npm run build && cp -r dist/ artifacts/" diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 27b819b..bf58ab7 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,16 @@ jobs: - name: Run ESLint run: | ./bin/run_eslint.sh src/ + + actionlint: + runs-on: ubuntu-latest + name: Run Linter for GitHub Actions Workflows + strategy: + matrix: + actionlint-version: ['1.7.7'] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Run actionlint + run: ./bin/run_actionlint.sh diff --git a/README.md b/README.md index 37f76e5..649e2b5 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,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](https://github.com/rhysd/actionlint) - Validates GitHub Actions workflow files +* [ESLint](https://eslint.org/) - Checks JavaScript/TypeScript code quality + +### Development Mode + ```bash $ PLATFORM= \ VERSION= \ 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..6fa8663 --- /dev/null +++ b/bin/run_actionlint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +# Run actionlint on the workflows directory +docker run \ + --rm \ + -v $(pwd):/repo \ + --workdir /repo \ + rhysd/actionlint:latest \ + -color