diff --git a/.dockerignore b/.dockerignore index ced02564a8..75b1506fbb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,6 @@ karma-reports/ .idea/ .tmp/ config.json* +matrix-js-sdk/ +matrix-react-sdk/ +matrix-analytics-events/ \ No newline at end of file diff --git a/.github/workflows/build_develop.yml b/.github/deactivated_workflows/build_develop.yml similarity index 95% rename from .github/workflows/build_develop.yml rename to .github/deactivated_workflows/build_develop.yml index 3a0670f978..dfc568d7c0 100644 --- a/.github/workflows/build_develop.yml +++ b/.github/deactivated_workflows/build_develop.yml @@ -22,9 +22,10 @@ jobs: - uses: actions/setup-node@v3 with: cache: 'yarn' + node-version: 14 - name: Install Dependencies - run: "./scripts/layered.sh" + run: "./scripts/layered.with.version.sh" - name: Build, Package & Upload sourcemaps run: "./scripts/ci_package.sh" diff --git a/.github/workflows/dockerhub.yaml b/.github/deactivated_workflows/dockerhub.yaml similarity index 100% rename from .github/workflows/dockerhub.yaml rename to .github/deactivated_workflows/dockerhub.yaml diff --git a/.github/workflows/issue_closed.yml b/.github/deactivated_workflows/issue_closed.yml similarity index 98% rename from .github/workflows/issue_closed.yml rename to .github/deactivated_workflows/issue_closed.yml index 9bc4e76a4a..4a81c4d8a3 100644 --- a/.github/workflows/issue_closed.yml +++ b/.github/deactivated_workflows/issue_closed.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/github-script@v5 with: - # PAT needed as the GITHUB_TOKEN won't be able to see cross-references from other orgs (matrix-org) + # PAT needed as the GITHUB_TOKEN won't be able to see cross-references from other orgs (matrix-org) github-token: ${{ secrets.ELEMENT_BOT_TOKEN }} script: | const variables = { diff --git a/.github/workflows/pull_request.yaml b/.github/deactivated_workflows/pull_request.yaml similarity index 100% rename from .github/workflows/pull_request.yaml rename to .github/deactivated_workflows/pull_request.yaml diff --git a/.github/workflows/sonarqube.yml b/.github/deactivated_workflows/sonarqube.yml similarity index 100% rename from .github/workflows/sonarqube.yml rename to .github/deactivated_workflows/sonarqube.yml diff --git a/.github/workflows/triage-assigned.yml b/.github/deactivated_workflows/triage-assigned.yml similarity index 100% rename from .github/workflows/triage-assigned.yml rename to .github/deactivated_workflows/triage-assigned.yml diff --git a/.github/workflows/triage-incoming.yml b/.github/deactivated_workflows/triage-incoming.yml similarity index 100% rename from .github/workflows/triage-incoming.yml rename to .github/deactivated_workflows/triage-incoming.yml diff --git a/.github/workflows/triage-labelled.yml b/.github/deactivated_workflows/triage-labelled.yml similarity index 100% rename from .github/workflows/triage-labelled.yml rename to .github/deactivated_workflows/triage-labelled.yml diff --git a/.github/workflows/triage-move-review-requests.yml b/.github/deactivated_workflows/triage-move-review-requests.yml similarity index 100% rename from .github/workflows/triage-move-review-requests.yml rename to .github/deactivated_workflows/triage-move-review-requests.yml diff --git a/.github/workflows/triage-priority-bugs.yml b/.github/deactivated_workflows/triage-priority-bugs.yml similarity index 100% rename from .github/workflows/triage-priority-bugs.yml rename to .github/deactivated_workflows/triage-priority-bugs.yml diff --git a/.github/workflows/triage-unlabelled.yml b/.github/deactivated_workflows/triage-unlabelled.yml similarity index 100% rename from .github/workflows/triage-unlabelled.yml rename to .github/deactivated_workflows/triage-unlabelled.yml diff --git a/.github/workflows/upgrade_dependencies.yml b/.github/deactivated_workflows/upgrade_dependencies.yml similarity index 100% rename from .github/workflows/upgrade_dependencies.yml rename to .github/deactivated_workflows/upgrade_dependencies.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab94c0e9ca..2e26697d2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,5 @@ +#Build the application +#tchap modification : use "./scripts/layered.with.version.sh" instead of "./scripts/layered.sh" name: Build on: pull_request: { } @@ -18,9 +20,10 @@ jobs: - uses: actions/setup-node@v3 with: cache: 'yarn' + node-version: 14 - name: Install Dependencies - run: "./scripts/layered.sh" + run: "./scripts/layered.with.version.sh" - name: Build run: "yarn build" diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml index 98cf39a156..c34eb2a9f9 100644 --- a/.github/workflows/static_analysis.yaml +++ b/.github/workflows/static_analysis.yaml @@ -1,3 +1,5 @@ +#Run a static analysis +#tchap modification : use "./scripts/layered.with.version.sh" instead of "./scripts/layered.sh" name: Static Analysis on: pull_request: { } @@ -19,16 +21,18 @@ jobs: - uses: actions/setup-node@v3 with: cache: 'yarn' + node-version: 14 - name: Install Dependencies - run: "./scripts/layered.sh" + run: "./scripts/layered.with.version.sh" - name: Typecheck run: "yarn run lint:types" - i18n_lint: - name: "i18n Check" - uses: matrix-org/matrix-react-sdk/.github/workflows/i18n_check.yml@develop +# tchap : tchap does not use extensively i18n +# i18n_lint: +# name: "i18n Check" +# uses: matrix-org/matrix-react-sdk/.github/workflows/i18n_check.yml@develop js_lint: name: "ESLint" @@ -39,6 +43,7 @@ jobs: - uses: actions/setup-node@v3 with: cache: 'yarn' + node-version: 14 # Does not need branch matching as only analyses this layer - name: Install Deps @@ -56,26 +61,29 @@ jobs: - uses: actions/setup-node@v3 with: cache: 'yarn' + node-version: 14 # Needs branch matching as it inherits .stylelintrc.js from matrix-react-sdk - name: Install Dependencies - run: "./scripts/layered.sh" + run: "./scripts/layered.with.version.sh" - name: Run Linter run: "yarn run lint:style" - analyse_dead_code: - name: "Analyse Dead Code" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 +# 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' + # - uses: actions/setup-node@v3 + # with: + # cache: 'yarn' + # node-version: 14 - - name: Install Deps - run: "scripts/layered.sh" + # - name: Install Deps + # run: "scripts/layered.with.version.sh" - - name: Dead Code Analysis - run: "yarn run analyse:unused-exports" + # - name: Dead Code Analysis + # run: "yarn run analyse:unused-exports" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ea3bbf8b82..75d9ec8745 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,3 +1,5 @@ +#Run the tests +#tchap modification : use "./scripts/layered.with.version.sh" instead of "./scripts/layered.sh" name: Tests on: pull_request: { } @@ -21,9 +23,10 @@ jobs: uses: actions/setup-node@v3 with: cache: 'yarn' + node-version: 14 - name: Install Dependencies - run: "./scripts/layered.sh" + run: "./scripts/layered.with.version.sh" - name: Run tests with coverage run: "yarn coverage --ci" diff --git a/package.json b/package.json index 0582405d58..e92456676c 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,6 @@ "package.json", "contribute.json" ], - "engines": { - "node": ">=14.19 <15" - }, "style": "bundle.css", "scripts": { "i18n": "matrix-gen-i18n", @@ -218,5 +215,8 @@ "jestSonar": { "reportPath": "coverage", "sonar56x": true + }, + "engines": { + "node": ">=14.19 <15" } } diff --git a/scripts/fetchdep.sh b/scripts/fetchdep.sh new file mode 100755 index 0000000000..e16b7279c4 --- /dev/null +++ b/scripts/fetchdep.sh @@ -0,0 +1,81 @@ +#!/bin/bash +#copied from matrix-react-sdk/scripts + +set -x + +deforg="$1" +defrepo="$2" +defbranch="$3" + +[ -z "$defbranch" ] && defbranch="develop" + +rm -r "$defrepo" || true + +PR_ORG=${PR_ORG:-"matrix-org"} +PR_REPO=${PR_REPO:-"matrix-react-sdk"} + +# A function that clones a branch of a repo based on the org, repo and branch +clone() { + org=$1 + repo=$2 + branch=$3 + if [ -n "$branch" ] + then + echo "Trying to use $org/$repo#$branch" + # Disable auth prompts: https://serverfault.com/a/665959 + GIT_TERMINAL_PROMPT=0 git clone https://github.com/$org/$repo.git $repo --branch "$branch" --depth 1 && exit 0 + fi +} + +# A function that gets info about a PR from the GitHub API based on its number +getPRInfo() { + number=$1 + if [ -n "$number" ]; then + echo "Getting info about a PR with number $number" + + apiEndpoint="https://api.github.com/repos/$PR_ORG/$PR_REPO/pulls/$number" + + head=$(curl $apiEndpoint | jq -r '.head.label') + fi +} + +# Some CIs don't give us enough info, so we just get the PR number and ask the +# GH API for more info - "fork:branch". Some give us this directly. +if [ -n "$BUILDKITE_BRANCH" ]; then + # BuildKite + head=$BUILDKITE_BRANCH +elif [ -n "$PR_NUMBER" ]; then + # GitHub + getPRInfo $PR_NUMBER +elif [ -n "$REVIEW_ID" ]; then + # Netlify + getPRInfo $REVIEW_ID +fi + +# for forks, $head will be in the format "fork:branch", so we split it by ":" +# into an array. On non-forks, this has the effect of splitting into a single +# element array given ":" shouldn't appear in the head - it'll just be the +# branch name. Based on the results, we clone. +BRANCH_ARRAY=(${head//:/ }) +TRY_ORG=$deforg +TRY_BRANCH=${BRANCH_ARRAY[0]} +if [[ "$head" == *":"* ]]; then + # ... but only match that fork if it's a real fork + if [ "${BRANCH_ARRAY[0]}" != "$PR_ORG" ]; then + TRY_ORG=${BRANCH_ARRAY[0]} + fi + TRY_BRANCH=${BRANCH_ARRAY[1]} +fi +clone ${TRY_ORG} $defrepo ${TRY_BRANCH} + +# Try the target branch of the push or PR. +if [ -n "$GITHUB_BASE_REF" ]; then + clone $deforg $defrepo $GITHUB_BASE_REF +elif [ -n "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" ]; then + clone $deforg $defrepo $BUILDKITE_PULL_REQUEST_BASE_BRANCH +fi + +# Try HEAD which is the branch name in Netlify (not BRANCH which is pull/xxxx/head for PR builds) +clone $deforg $defrepo $HEAD +# Use the default branch as the last resort. +clone $deforg $defrepo $defbranch diff --git a/scripts/layered.with.version.sh b/scripts/layered.with.version.sh new file mode 100755 index 0000000000..930d3288d9 --- /dev/null +++ b/scripts/layered.with.version.sh @@ -0,0 +1,54 @@ +#!/bin/bash +#inspired from ./layered.sh +set -x + +# Creates a layered environment with the full repo for the app and SDKs cloned +# and linked. This gives an tchap-web dev environment ready to build with +# matching branches of react-sdk's dependencies so that changes can be tested +# in tchap-web. + +# Note that this style is different from the recommended developer setup: this +# file nests js-sdk and matrix-react-sdk inside element-web, while the local +# development setup places them all at the same level. We are nesting them here +# because some CI systems do not allow moving to a directory above the checkout +# for the primary repo (element-web in this case). + +# Install dependencies, as we'll be using fetchdep.sh from matrix-react-sdk +yarn install --pure-lockfile + +# Pass appropriate repo to fetchdep.sh (not needed for tchap-web) +#export PR_ORG=vector-im +#export PR_REPO=element-web + +#tchap added : grep matrix dependencies version from package.json +export MATRIX_JS_SDK_VERSION=$(awk -F \" '/"matrix-js-sdk": ".+"/ { print $4; exit; }' package.json) +export MATRIX_REACT_SDK_VERSION=$(awk -F \" '/"matrix-react-sdk": ".+"/ { print $4; exit; }' package.json) + +# Set up the js-sdk first +./scripts/fetchdep.sh matrix-org matrix-js-sdk v$MATRIX_JS_SDK_VERSION +pushd matrix-js-sdk +yarn link +yarn install --pure-lockfile +popd + +# Also set up matrix-analytics-events so we get the latest from +# the main branch or a branch with matching name +./scripts/fetchdep.sh matrix-org matrix-analytics-events main +pushd matrix-analytics-events +yarn link +yarn install --pure-lockfile +yarn build:ts +popd + +# Now set up the react-sdk +./scripts/fetchdep.sh matrix-org matrix-react-sdk v$MATRIX_REACT_SDK_VERSION +pushd matrix-react-sdk +yarn link +yarn link matrix-js-sdk +yarn link @matrix-org/analytics-events +yarn install --pure-lockfile +popd + +# Link the layers into element-web +yarn link matrix-js-sdk +yarn link matrix-react-sdk