From ab4f0ef4a1a791f3d234a863a2d687c4b94bd23c Mon Sep 17 00:00:00 2001 From: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> Date: Tue, 10 Jan 2023 20:31:26 +0530 Subject: [PATCH] =?UTF-8?q?build:=20add=20CI=20workflow=20=F0=9F=95=BA=20(?= =?UTF-8?q?#671)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build: add CI workflow 🕺 Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * refactor: use correct event in CT workflow Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * feat: setup Pipeline 🚰 Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * style: fix lint issues in Dockerfile Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * refactor: automerger now requires CI & CT Workflows Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * chore: add name for CodeQL workflow Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * fix: add ignore files for prettier & eslint Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * chore(deps): bump pinned apt-get packages Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * feat: add `hadolint` config file Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * fix: correct workflow file for automerger Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> * style: remove pinned versions of apt deps Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com> --- .eslintignore | 1 + .github/workflows/automerger.yml | 6 +--- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++ .github/workflows/codeql.yml | 2 ++ .github/workflows/ct.yml | 7 +---- .github/workflows/pipeline.yml | 43 +++++++++++++++++++++++++++ .hadolint.yml | 3 ++ .prettierignore | 1 + Dockerfile | 32 ++++++++++++++++---- 9 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 .eslintignore create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pipeline.yml create mode 100644 .hadolint.yml create mode 100644 .prettierignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..a48cf0d --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +public diff --git a/.github/workflows/automerger.yml b/.github/workflows/automerger.yml index 78607f4..ee097e9 100644 --- a/.github/workflows/automerger.yml +++ b/.github/workflows/automerger.yml @@ -1,9 +1,7 @@ name: 'Auto Merge PRs' on: - pull_request: - branches: - - master + workflow_call: permissions: pull-requests: write @@ -12,8 +10,6 @@ permissions: jobs: automerge: runs-on: ubuntu-latest - if: > - github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' steps: - uses: fastify/github-action-merge-dependabot@v3 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..94f01b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: 'Continuous Integration' + +on: + workflow_call: + +permissions: + checks: write + contents: read + +jobs: + ci: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository ✨ (non-dependabot) + if: ${{ github.actor != 'dependabot[bot]' }} + uses: actions/checkout@v3 + + - name: Check out repository 🎉 (dependabot) + if: ${{ github.actor == 'dependabot[bot]' }} + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup node env 📦 + uses: actions/setup-node@v3 + with: + node-version-file: 'package.json' + check-latest: true + cache: 'npm' + + - name: Install dependencies 🚀 + run: npm ci --prefer-offline --no-audit --omit=optional + + - name: Run linter(s) 💅 + uses: wearerequired/lint-action@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + continue_on_error: false + git_name: github-actions[bot] + git_email: github-actions[bot]@users.noreply.github.com + auto_fix: false + eslint: true + eslint_extensions: js,cjs,mjs,ts + prettier: true + prettier_extensions: js,cjs,ts,json + + - name: Run hadolint 🐳 + uses: hadolint/hadolint-action@v3.0.0 + with: + dockerfile: Dockerfile + ignore: DL3008,DL3015 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5acb039..d4df176 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,3 +1,5 @@ +name: 'CodeQL' + on: push: branches: diff --git a/.github/workflows/ct.yml b/.github/workflows/ct.yml index f7b55c3..b1cfd34 100644 --- a/.github/workflows/ct.yml +++ b/.github/workflows/ct.yml @@ -1,12 +1,7 @@ name: 'Continuous Testing' on: - push: - branches: - - master - pull_request: - branches: - - master + workflow_call: permissions: checks: write diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..8432a18 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,43 @@ +name: 'The Pipeline' + +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: ci-${{ github.ref }}-1 + cancel-in-progress: true + +jobs: + extract-branch: + name: 'Fetch branch' + runs-on: ubuntu-latest + outputs: + current_branch: ${{ steps.get-branch.outputs.current_branch }} + steps: + - name: Extract branch name 🕊 + id: get-branch + run: echo "current_branch=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT + ci: + name: 'CI' + needs: + - extract-branch + uses: maptiler/tileserver-gl/.github/workflows/ci.yml@master + ct: + name: 'CT' + needs: + - extract-branch + uses: maptiler/tileserver-gl/.github/workflows/ct.yml@master + automerger: + name: 'Automerge Dependabot PRs' + needs: + - ci + - ct + - extract-branch + if: > + github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' + uses: maptiler/tileserver-gl/.github/workflows/automerger.yml@master diff --git a/.hadolint.yml b/.hadolint.yml new file mode 100644 index 0000000..438a9dd --- /dev/null +++ b/.hadolint.yml @@ -0,0 +1,3 @@ +ignored: + - DL3008 + - DL3015 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..a48cf0d --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +public diff --git a/Dockerfile b/Dockerfile index 0644af3..632d74c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,19 +20,32 @@ RUN set -ex; \ libjpeg-dev \ libgif-dev \ librsvg2-dev \ + gir1.2-rsvg-2.0 \ + librsvg2-2 \ + librsvg2-common \ libcurl4-openssl-dev \ - libpixman-1-dev; \ - wget -qO- https://deb.nodesource.com/setup_18.x | bash; \ + libpixman-1-dev \ + libpixman-1-0; \ + apt-get -y --purge autoremove; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN wget -qO- https://deb.nodesource.com/setup_18.x | bash; \ apt-get install -y nodejs; \ + npm i -g npm@latest; \ apt-get -y remove wget; \ apt-get -y --purge autoremove; \ apt-get clean; \ rm -rf /var/lib/apt/lists/*; RUN mkdir -p /usr/src/app -COPY package* /usr/src/app/ +COPY package* /usr/src/app -RUN cd /usr/src/app && npm ci --omit=dev +WORKDIR /usr/src/app + +RUN npm install --omit=dev FROM ubuntu:focal AS final @@ -60,9 +73,16 @@ RUN set -ex; \ libpixman-1-0 \ libcurl4 \ librsvg2-2 \ - libpango1.0; \ - wget -qO- https://deb.nodesource.com/setup_18.x | bash; \ + libpango-1.0-0; \ + apt-get -y --purge autoremove; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/*; + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN wget -qO- https://deb.nodesource.com/setup_18.x | bash; \ apt-get install -y nodejs; \ + npm i -g npm@latest; \ apt-get -y remove wget; \ apt-get -y --purge autoremove; \ apt-get clean; \