From 20194de707244dc5704da52917164d4000e78819 Mon Sep 17 00:00:00 2001 From: Olivier D Date: Mon, 3 Apr 2023 10:35:35 +0200 Subject: [PATCH] unify package scripts, move ci files to tchap scripts folder (#519) * move ci files to tchap scripts folder * fix lint * avoid using install-yarn-linked-repositories when not necessary * unify tchap package of scalingo and github * add yarn install * add yarn linkedin dependencies --- .github/workflows/build.yml | 3 +- .github/workflows/create-release.yml | 13 ++++-- .github/workflows/static_analysis.yaml | 20 +-------- .prettierignore | 1 + package.json | 7 ++- .../tchap-common/css/_tchap_custom.pcss | 4 +- scripts/{ => tchap}/fetchdep.with.version.sh | 0 .../get-version-from-package-json.sh | 0 .../tchap/install-yarn-linked-repositories.sh | 4 +- scripts/{ => tchap}/package-github.sh | 4 +- scripts/{ => tchap}/package-scalingo-prod.sh | 9 ++-- scripts/tchap/package-tchap.sh | 43 +++++++++++++++++++ scripts/{ => tchap}/scalingo-deploy.sh | 0 src/util/TchapUrls.ts | 6 +-- 14 files changed, 74 insertions(+), 40 deletions(-) rename scripts/{ => tchap}/fetchdep.with.version.sh (100%) rename scripts/{ => tchap}/get-version-from-package-json.sh (100%) rename scripts/{ => tchap}/package-github.sh (91%) rename scripts/{ => tchap}/package-scalingo-prod.sh (77%) create mode 100755 scripts/tchap/package-tchap.sh rename scripts/{ => tchap}/scalingo-deploy.sh (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b978a92b2b..67847f1942 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,4 @@ #Build the application -#tchap modification : use "./scripts/tchap/install-yarn-linked-repositories.sh" instead of "./scripts/layered.sh" name: Build on: pull_request: {} @@ -23,7 +22,7 @@ jobs: node-version: 16 - name: Install Dependencies - run: "./scripts/tchap/install-yarn-linked-repositories.sh" + run: "yarn install" - name: Build run: "yarn build" diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 0c9e368208..4c8fea3271 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,4 +1,4 @@ -name: Create tag and release for tchap-web +name: Build archives and create release for tchap-web on tag "tchap-" on: push: @@ -11,6 +11,7 @@ jobs: permissions: contents: write steps: + #Build artifacts for dev, preprod and prod - uses: actions/checkout@v3 - name: Get Node Version id: node_version @@ -19,24 +20,28 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ steps.node_version.outputs.node_version }} + - name: Install Dependencies + run: "yarn install" - name: Get Tchap Web Version id: version run: echo ::set-output name=version::$(node -e 'console.log(require("./package.json").version)') - name: Build the archive ${{ steps.version.outputs.version }} for dev - run: scripts/package-github.sh + run: scripts/tchap/package-tchap.sh env: CONFIG: dev - name: Build the archive ${{ steps.version.outputs.version }} for preprod - run: scripts/package-github.sh + run: scripts/tchap/package-tchap.sh env: CONFIG: preprod - name: Build the archive ${{ steps.version.outputs.version }} for prod - run: scripts/package-github.sh + run: scripts/tchap/package-tchap.sh env: CONFIG: prod - name: Get current date id: date run: echo "::set-output name=date::$(date +'%Y%m%d')" + + #create release - name: Create tchap-web release uses: ncipollo/release-action@v1 with: diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml index 77714bd156..22a5b03b89 100644 --- a/.github/workflows/static_analysis.yaml +++ b/.github/workflows/static_analysis.yaml @@ -1,5 +1,4 @@ #Run a static analysis -#tchap modification : use "./scripts/tchap/install-yarn-linked-repositories.sh" instead of "./scripts/layered.sh" name: Static Analysis on: pull_request: {} @@ -68,24 +67,7 @@ jobs: # Needs branch matching as it inherits .stylelintrc.js from matrix-react-sdk - name: Install Dependencies - run: "./scripts/tchap/install-yarn-linked-repositories.sh" + run: "yarn install --pure-lockfile" - name: Run Linter run: "yarn run lint:style" -# tchap : analyse:unused-exports does not work well with tchap customisations, it raises exception for "default export" not used -#analyse_dead_code: -# name: "Analyse Dead Code" -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v2 - -# - uses: actions/setup-node@v3 -# with: -# cache: 'yarn' -# node-version: 16 - -# - name: Install Deps -# run: "scripts/tchap/install-yarn-linked-repositories.sh" - -# - name: Dead Code Analysis -# run: "yarn run analyse:unused-exports" diff --git a/.prettierignore b/.prettierignore index c9f5f08f95..8d84823e9e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -28,3 +28,4 @@ src/vector/modernizr.js #remove tchap files from prettier patches/patches.json +yarn-linked-dependencies/ \ No newline at end of file diff --git a/package.json b/package.json index a76c3cc871..a93400eb30 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,9 @@ "contribute.json" ], "style": "bundle.css", + "scripts_comments": { + "build:jitsi": "tchap don't need that, deactivate?" + }, "scripts": { "i18n": "matrix-gen-i18n", "prunei18n": "matrix-prune-i18n", @@ -43,8 +46,8 @@ "build:module_system": "tsc --project ./tsconfig.module_system.json && node ./lib/module_system/scripts/install.js", "build:github": "yarn build:genfiles && yarn build:bundle", "dist": "scripts/package.sh", - "scalingo-postbuild": "scripts/package-scalingo-prod.sh", - "start": "export VERSION=$(scripts/get-version-from-package-json.sh) && yarn build:module_system && concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js\"", + "scalingo-postbuild": "scripts/tchap/package-tchap.sh", + "start": "export VERSION=$(scripts/tchap/get-version-from-package-json.sh) && yarn build:module_system && concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js\"", "start:https": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n res,element-js \"yarn start:res\" \"yarn start:js --https\"", "start:res": "yarn build:jitsi && node scripts/copy-res.js -w", "start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --mode development --disable-host-check --hot", diff --git a/res/themes/tchap-common/css/_tchap_custom.pcss b/res/themes/tchap-common/css/_tchap_custom.pcss index 10ee8407ad..37414d8f72 100644 --- a/res/themes/tchap-common/css/_tchap_custom.pcss +++ b/res/themes/tchap-common/css/_tchap_custom.pcss @@ -19,7 +19,7 @@ div.mx_SettingsTab.mx_SecurityUserSettingsTab > div:nth-child(4) > div:nth-child } /* change link color and decoration in login error when email is not autorized */ -.mx_Login_error.mx_Login_error_link{ +.mx_Login_error.mx_Login_error_link { color: $alert important!; text-decoration: underline important!; -} \ No newline at end of file +} diff --git a/scripts/fetchdep.with.version.sh b/scripts/tchap/fetchdep.with.version.sh similarity index 100% rename from scripts/fetchdep.with.version.sh rename to scripts/tchap/fetchdep.with.version.sh diff --git a/scripts/get-version-from-package-json.sh b/scripts/tchap/get-version-from-package-json.sh similarity index 100% rename from scripts/get-version-from-package-json.sh rename to scripts/tchap/get-version-from-package-json.sh diff --git a/scripts/tchap/install-yarn-linked-repositories.sh b/scripts/tchap/install-yarn-linked-repositories.sh index a60458cf42..d4d6630d97 100755 --- a/scripts/tchap/install-yarn-linked-repositories.sh +++ b/scripts/tchap/install-yarn-linked-repositories.sh @@ -32,7 +32,7 @@ mkdir -p yarn-linked-dependencies cd yarn-linked-dependencies # Set up the js-sdk first -../scripts/fetchdep.with.version.sh matrix-org matrix-js-sdk $MATRIX_JS_SDK_VERSION +../scripts/tchap/fetchdep.with.version.sh matrix-org matrix-js-sdk $MATRIX_JS_SDK_VERSION pushd matrix-js-sdk yarn unlink # :TCHAP: for local build, undo previous links if present. yarn link @@ -50,7 +50,7 @@ popd #popd # Now set up the react-sdk -../scripts/fetchdep.with.version.sh matrix-org matrix-react-sdk $MATRIX_REACT_SDK_VERSION +../scripts/tchap/fetchdep.with.version.sh matrix-org matrix-react-sdk $MATRIX_REACT_SDK_VERSION pushd matrix-react-sdk yarn unlink # :TCHAP: for local build, undo previous links if present. yarn link diff --git a/scripts/package-github.sh b/scripts/tchap/package-github.sh similarity index 91% rename from scripts/package-github.sh rename to scripts/tchap/package-github.sh index 76151e35c8..1e94c63205 100755 --- a/scripts/package-github.sh +++ b/scripts/tchap/package-github.sh @@ -1,12 +1,14 @@ #!/bin/bash +#DEPRECRATED, see package-tchap.sh + # Tchap: File copied from scripts/package.json. set -e today=$(date +%Y%m%d) -version=$(./scripts/get-version-from-package-json.sh) +version=$(./scripts/tchap/get-version-from-package-json.sh) export VERSION=$version echo "VERSION is set to $VERSION" diff --git a/scripts/package-scalingo-prod.sh b/scripts/tchap/package-scalingo-prod.sh similarity index 77% rename from scripts/package-scalingo-prod.sh rename to scripts/tchap/package-scalingo-prod.sh index dcbafc2397..a7762fa09a 100755 --- a/scripts/package-scalingo-prod.sh +++ b/scripts/tchap/package-scalingo-prod.sh @@ -1,12 +1,15 @@ #!/bin/bash +#DEPRECRATED, see package-tchap.sh + # Tchap: File copied from scripts/package.json. +# use package-github instead set -e today=$(date +%Y%m%d) -version=$(./scripts/get-version-from-package-json.sh) +version=$(./scripts/tchap/get-version-from-package-json.sh) export VERSION=$version echo "VERSION is set to $VERSION" @@ -33,8 +36,8 @@ fi # Copy the files in /dist, ready to be served. cp -r tchap-$version/* dist/ -# Also make a tar file. Useful for releases. -tar chvzf tchap-$version-$CONFIG-$today.tar.gz dist +# Also make a tar file. Useful for releases. EDIT: not needed +#tar chvzf tchap-$version-$CONFIG-$today.tar.gz dist rm -r tchap-$version echo diff --git a/scripts/tchap/package-tchap.sh b/scripts/tchap/package-tchap.sh new file mode 100755 index 0000000000..c1efe27250 --- /dev/null +++ b/scripts/tchap/package-tchap.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Tchap: File copied from scripts/package.js +# This file is meant to be used in scalingo and github actions + +set -e + +today=$(date +%Y%m%d) + +version=$(./scripts/tchap/get-version-from-package-json.sh) +export VERSION=$version +echo "VERSION is set to $VERSION" + +if [[ -n "$CONFIG" ]]; then + echo "CONFIG=$CONFIG" + cp "config.$CONFIG.json" config.json + echo "Using config.$CONFIG.json" +else + echo "No config specified, using config.json." +fi + +yarn clean +yarn build + +mkdir -p dist +cp -r webapp tchap-$version + +# if $version looks like semver with leading v, strip it before writing to file +if [[ ${version} =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-.+)?$ ]]; then + echo ${version:1} > tchap-$version/version +else + echo ${version} > tchap-$version/version +fi + +# Copy the files in /dist, ready to be served. +cp -r tchap-$version/* dist/ + +# Also make a tar file. Useful for releases. +#tar chvzf tchap-$version-$CONFIG-$today.tar.gz dist +rm -r tchap-$version + +echo +echo "Packaged tchap-$version-$CONFIG" diff --git a/scripts/scalingo-deploy.sh b/scripts/tchap/scalingo-deploy.sh similarity index 100% rename from scripts/scalingo-deploy.sh rename to scripts/tchap/scalingo-deploy.sh diff --git a/src/util/TchapUrls.ts b/src/util/TchapUrls.ts index 7dd0bfcabd..36c7bdbfab 100644 --- a/src/util/TchapUrls.ts +++ b/src/util/TchapUrls.ts @@ -1,8 +1,4 @@ - - export default class TchapUrls { - //url to request the opening of a new domain on Tchap public static requestDomainUrl = "https://www.demarches-simplifiees.fr/commencer/utiliser-tchap"; - -} \ No newline at end of file +}