From fec316f59b41b1c0c364775a31643deaa6944ce4 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 24 Feb 2025 13:35:53 -0500 Subject: [PATCH] Add precommit check --- .github/workflows/ci.yml | 106 +++++++++++++++++----------------- .github/workflows/deploy.yml | 22 +++---- .github/workflows/release.yml | 3 +- .pre-commit-config.yaml | 21 +++++++ 4 files changed, 86 insertions(+), 66 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02583f4d5..95e0cac24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ jobs: if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} steps: - - uses: actions/checkout@v4 - - run: docker build -t test-docker-image-build . + - uses: actions/checkout@v4 + - run: docker build -t test-docker-image-build . # build the editor build-node: @@ -27,17 +27,17 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ ubuntu-latest, windows-latest, macos-latest ] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - run: npm ci - - run: npm run build - - run: npm run lint - - run: npm run lint-css + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + - run: npm ci + - run: npm run build + - run: npm run lint + - run: npm run lint-css @@ -47,53 +47,53 @@ jobs: if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - run: npm ci - - run: npm run build - - name: artifacts/maputnik - uses: actions/upload-artifact@v4 - with: - name: maputnik - path: dist - - # Build and upload desktop CLI artifacts - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: ^1.23.x - cache-dependency-path: desktop/go.sum - id: go - - - name: Build desktop artifacts - run: npm run build-desktop - - - name: Artifacts/linux - uses: actions/upload-artifact@v4 - with: - name: maputnik-linux - path: ./desktop/bin/linux/ - - - name: Artifacts/darwin - uses: actions/upload-artifact@v4 - with: - name: maputnik-darwin - path: ./desktop/bin/darwin/ - - - name: Artifacts/windows - uses: actions/upload-artifact@v4 - with: - name: maputnik-windows - path: ./desktop/bin/windows/ - + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + - run: npm ci + - run: npm run build + - name: artifacts/maputnik + uses: actions/upload-artifact@v4 + with: + name: maputnik + path: dist + + # Build and upload desktop CLI artifacts + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ^1.23.x + cache-dependency-path: desktop/go.sum + id: go + + - name: Build desktop artifacts + run: npm run build-desktop + + - name: Artifacts/linux + uses: actions/upload-artifact@v4 + with: + name: maputnik-linux + path: ./desktop/bin/linux/ + + - name: Artifacts/darwin + uses: actions/upload-artifact@v4 + with: + name: maputnik-darwin + path: ./desktop/bin/darwin/ + + - name: Artifacts/windows + uses: actions/upload-artifact@v4 + with: + name: maputnik-windows + path: ./desktop/bin/windows/ + e2e-tests: name: "E2E tests using ${{ matrix.browser }}" strategy: fail-fast: false matrix: - browser: [chrome] + browser: [ chrome ] runs-on: ubuntu-22.04 steps: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4a8b5c3cc..2cb7f9731 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,7 +20,7 @@ jobs: - name: Install run: npm ci - - name: Build + - name: Build run: npm run build - name: Upload to GitHub Pages @@ -28,7 +28,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: dist - + # publish docker to GitHub registry deploy-docker: name: deploy/docker @@ -40,12 +40,12 @@ jobs: fail-fast: false steps: - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@v4 - - run: docker build -t ghcr.io/maplibre/maputnik:main . - - run: docker push ghcr.io/maplibre/maputnik:main + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v4 + - run: docker build -t ghcr.io/maplibre/maputnik:main . + - run: docker push ghcr.io/maplibre/maputnik:main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 944304e92..f41b97caa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: push: - branches: [main] + branches: [ main ] workflow_dispatch: jobs: @@ -99,4 +99,3 @@ jobs: allowUpdates: true draft: false prerelease: false - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..a19e5136e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-executables-have-shebangs + - id: check-json + exclude: '.+/tsconfig.json' + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-toml + - id: check-yaml + args: [ --allow-multiple-documents ] + - id: destroyed-symlinks + - id: end-of-file-fixer + - id: mixed-line-ending + args: [ --fix=lf ] + - id: trailing-whitespace