From 86233f0977711c1a64aa6e838d372acc472accf3 Mon Sep 17 00:00:00 2001 From: Daniel Leroux Date: Tue, 20 Sep 2022 11:29:12 +0200 Subject: [PATCH] ci(build): Add build jobs --- .github/ISSUE_TEMPLATE | 63 ++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE | 29 ++++++++++ .github/workflows/actions/build/action.yml | 32 +++++++++++ .github/workflows/actions/test/action.yml | 13 +++++ .github/workflows/build.yml | 17 ++++++ .github/workflows/pre-publish.yml | 19 +++++++ .github/workflows/publish.yml | 19 +++++++ package.json | 5 +- tests/is-icon-generated.mjs | 34 ++++++++++++ yarn.lock | 37 ++++++++++++- 10 files changed, 266 insertions(+), 2 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE create mode 100644 .github/PULL_REQUEST_TEMPLATE create mode 100644 .github/workflows/actions/build/action.yml create mode 100644 .github/workflows/actions/test/action.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/pre-publish.yml create mode 100644 .github/workflows/publish.yml create mode 100644 tests/is-icon-generated.mjs diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE new file mode 100644 index 0000000..f8a7573 --- /dev/null +++ b/.github/ISSUE_TEMPLATE @@ -0,0 +1,63 @@ + + +## I'm submitting a... + + +

+[ ] Regression (a behavior that used to work and stopped working in a new release)
+[ ] Bug report
+[ ] Performance issue
+[ ] Feature request
+[ ] Documentation issue or request
+[ ] Support request
+[ ] Other... Please describe:
+
+ +## Current behavior + + + +## Expected behavior + + + +## Minimal reproduction of the problem with instructions + + + +## What is the motivation / use case for changing the behavior? + + + +## Environment + +- [ ] Upload `package.json`-dependencies: +- [ ] Upload `package-lock.json`-dependencies: + +

+- Environment: 
+- Installed version: XX
+
+Browser:
+- [ ] Chrome (desktop) version XX
+- [ ] Chrome (Android) version XX
+- [ ] Chrome (iOS) version XX
+- [ ] Firefox version XX
+- [ ] Safari (desktop) version XX
+- [ ] Safari (iOS) version XX
+- [ ] IE version XX
+- [ ] Edge version XX
+
+For Tooling issues:
+- Node version:  
+- Platform:  
+
+Others:
+
+
diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000..456ed65 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,29 @@ + + +## Summary + + + +## How did you test this change? + + diff --git a/.github/workflows/actions/build/action.yml b/.github/workflows/actions/build/action.yml new file mode 100644 index 0000000..485991f --- /dev/null +++ b/.github/workflows/actions/build/action.yml @@ -0,0 +1,32 @@ +name: 'Build Icons' +description: 'Build Icons' +runs: + using: 'composite' + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' + - name: configure yarnrc + run: | + echo 'yarn-offline-mirror ".yarn-cache/"' >> .yarnrc + echo 'yarn-offline-mirror-pruning true' >> .yarnrc + shell: bash + - uses: actions/cache@v2 + id: cache + with: + path: ./node_modules + key: yarn-modules-${{ hashFiles('yarn-lock.json') }} + - name: install + if: steps.cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --no-progress + shell: bash + - name: build + run: yarn build + shell: bash + - uses: actions/upload-artifact@v3 + with: + name: dist + path: | + dist diff --git a/.github/workflows/actions/test/action.yml b/.github/workflows/actions/test/action.yml new file mode 100644 index 0000000..37a08cf --- /dev/null +++ b/.github/workflows/actions/test/action.yml @@ -0,0 +1,13 @@ +name: 'Test Icons' +description: 'Test if all svg files are generated to dist' +runs: + using: 'composite' + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' + - name: build + run: yarn test + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..83fbaeb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +name: build + +on: + pull_request: + branches: ['**'] + +jobs: + build: + runs-on: ubuntu-latest + container: + image: node:16.16.0 + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@v3 + - uses: ./.github/workflows/actions/build + - uses: ./.github/workflows/actions/test diff --git a/.github/workflows/pre-publish.yml b/.github/workflows/pre-publish.yml new file mode 100644 index 0000000..4b313b7 --- /dev/null +++ b/.github/workflows/pre-publish.yml @@ -0,0 +1,19 @@ +name: publish + +on: + release: + types: [prerelease] + +jobs: + build: + runs-on: ubuntu-latest + container: + image: node:16.16.0 + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@v3 + - uses: ./.github/workflows/actions/build + - uses: ./.github/workflows/actions/test + - name: publish lib + run: yarn publish --tag beta diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..69d47a2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,19 @@ +name: publish + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + container: + image: node:16.16.0 + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@v3 + - uses: ./.github/workflows/actions/build + - uses: ./.github/workflows/actions/test + - name: publish lib + run: yarn publish diff --git a/package.json b/package.json index 71940cb..d7f11f5 100755 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ }, "scripts": { "start": "gulp watch", - "build": "gulp symbols" + "build": "gulp symbols", + "test": "node ./tests/is-icon-generated.mjs.mjs" }, "private": false, "files": [ @@ -31,6 +32,8 @@ "dist/sample.json" ], "devDependencies": { + "@types/fs-extra": "^9.0.13", + "fs-extra": "^10.1.0", "gulp": "^4.0.2", "gulp-consolidate": "^0.2.0", "gulp-iconfont": "^11.0.0", diff --git a/tests/is-icon-generated.mjs b/tests/is-icon-generated.mjs new file mode 100644 index 0000000..6bcfa3a --- /dev/null +++ b/tests/is-icon-generated.mjs @@ -0,0 +1,34 @@ +/* + * SPDX-FileCopyrightText: 2022 Siemens AG + * + * SPDX-License-Identifier: MIT + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import fse from 'fs-extra'; +import path from 'path'; + +const __dirname = path.resolve(); + +async function main() { + const allsvgs = fse.readdirSync(path.join(__dirname, 'svg')); + const generatedCssFile = fse.readFileSync( + path.join(__dirname, 'dist', 'css', 'ix-icons.css') + ); + + allsvgs + .map((svg) => svg.replace('.svg', '')) + .forEach((svg) => { + if (generatedCssFile.includes(svg)) { + return; + } + + console.error(`${svg} is missing in dist/css/ix-icons.css`); + process.exit(1); + }); + + console.log('All svg files generated as svg'); +} + +main(); diff --git a/yarn.lock b/yarn.lock index 959f108..8c5d95e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28,6 +28,18 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== +"@types/fs-extra@^9.0.13": + version "9.0.13" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45" + integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA== + dependencies: + "@types/node" "*" + +"@types/node@*": + version "18.7.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.18.tgz#633184f55c322e4fb08612307c274ee6d5ed3154" + integrity sha512-m+6nTEOadJZuTPkKR/SYK3A2d7FZrgElol9UP1Kae90VVU4a6mxnPuLiIW1m4Cq4gZ/nWb9GrdVXJCoCazDAbg== + abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" @@ -1003,6 +1015,15 @@ fragment-cache@^0.2.1: dependencies: map-cache "^0.2.2" +fs-extra@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-minipass@^2.0.0, fs-minipass@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" @@ -1184,7 +1205,7 @@ glogg@^1.0.0: dependencies: sparkles "^1.0.0" -graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.6: +graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6: version "4.2.10" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== @@ -1825,6 +1846,15 @@ json-stable-stringify-without-jsonify@^1.0.1: resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + just-debounce@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/just-debounce/-/just-debounce-1.1.0.tgz#2f81a3ad4121a76bc7cb45dbf704c0d76a8e5ddf" @@ -3349,6 +3379,11 @@ unique-stream@^2.0.2: json-stable-stringify-without-jsonify "^1.0.1" through2-filter "^3.0.0" +universalify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== + unset-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"