From fe8c583e09d9941cfaa7cb42f4cd1f55d49c3fc0 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 27 Apr 2022 07:53:30 +0100 Subject: [PATCH] Attempt all of the CI --- .github/workflows/build.yaml | 42 ++++++++++++++ .github/workflows/deploy_develop.yaml | 59 ++++++++++++++++--- .github/workflows/static_analysis.yaml | 80 ++++++++++++++++++++++++++ .github/workflows/test.yaml | 29 ++++++++++ scripts/package.sh | 2 +- 5 files changed, 203 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/static_analysis.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..10e56068e1 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,42 @@ +name: Build +on: + pull_request: { } + push: + branches: [ master, develop ] + repository_dispatch: + types: [ element-web-notify ] +jobs: + build: + name: "Build" + runs-on: ubuntu-latest + env: + # This must be set for fetchdep.sh to get the right branch + PR_NUMBER: ${{github.event.number}} + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Install SDKs + run: "./scripts/fetch-develop.deps.sh --depth 1" + + - name: Install Dependencies + run: "yarn install" + + - name: Build & Package + run: "./scripts/ci_package.sh" + + - name: Upload webpack-stats.json + uses: actions/upload-artifact@v2 + with: + path: webpack-state.json + retention-days: 28 + + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: previewbuild + path: dist/*.tar.gz + retention-days: ${{ github.ref == 'develop' && 1 || 28 }} diff --git a/.github/workflows/deploy_develop.yaml b/.github/workflows/deploy_develop.yaml index 4d335a68c8..323babe178 100644 --- a/.github/workflows/deploy_develop.yaml +++ b/.github/workflows/deploy_develop.yaml @@ -1,17 +1,60 @@ -name: Trigger deployment to develop.element.io +name: Deploy develop.element.io +concurrency: develop_deploy on: - pull_request: { } # TEMP - push: - branches: [ develop ] - repository_dispatch: - types: [ element-web-notify ] + workflow_run: + workflows: [ "Build" ] + types: + - completed jobs: - trigger: + deploy: runs-on: ubuntu-latest +# if: github.ref == 'develop' steps: + - name: Create Deployment ID + uses: altinukshini/deployment-action@releases/v1 + id: deployment + with: + token: "${{ github.token }}" + target_url: https://develop.element.io + environment: production + + - name: Find Artifact ID + uses: actions/github-script@v3.1.0 + id: find_artifact + with: + result-encoding: string + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "previewbuild" + })[0]; + return matchArtifact.id; + + # TODO - name: Invoke deployment hook uses: distributhor/workflow-webhook@v2 env: webhook_url: https://test.tun.bit.ovh webhook_secret: FooBar - data: '{ "tarball_url": "foobar" }' + data: '{ "artifact_id": "${{steps.find_artifact.outputs.result}}" }' + + - name: Update deployment status (success) + if: success() + uses: altinukshini/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: https://develop.element.io + state: "success" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + - name: Update deployment status (failure) + if: failure() + uses: altinukshini/deployment-status@releases/v1 + with: + token: "${{ github.token }}" + target_url: https://develop.element.io + state: "failure" + deployment_id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml new file mode 100644 index 0000000000..be8ee9eaa3 --- /dev/null +++ b/.github/workflows/static_analysis.yaml @@ -0,0 +1,80 @@ +name: Static Analysis +on: + pull_request: { } + push: + branches: [ develop, master ] + repository_dispatch: + types: [ element-web-notify ] +jobs: + ts_lint: + name: "Typescript Syntax Check" + runs-on: ubuntu-latest + env: + # This must be set for fetchdep.sh to get the right branch + PR_NUMBER: ${{github.event.number}} + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Install SDKs + run: "./scripts/fetch-develop.deps.sh --depth 1" + + - name: Install Dependencies + run: "yarn install" + + - name: Typecheck + run: "yarn run lint:types" + + i18n_lint: + name: "i18n Diff Check" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + # Does not need branch matching as only analyses this layer + - name: Install Deps + run: "yarn install" + + - name: i18n Check + run: "yarn run diff-i18n" + + js_lint: + name: "ESLint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + # Does not need branch matching as only analyses this layer + - name: Install Deps + run: "yarn install" + + - name: Run Linter + run: "yarn run lint:js" + + style_lint: + name: "Style Lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + # Does not need branch matching as only analyses this layer + - name: Install Deps + run: "yarn install" + + - name: Run Linter + run: "yarn run lint:style" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000000..2be1ef5e1f --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Test +on: + pull_request: { } + push: + branches: [ master, develop ] + repository_dispatch: + types: [ element-web-notify ] +jobs: + test: + name: "Test" + runs-on: ubuntu-latest + env: + # This must be set for fetchdep.sh to get the right branch + PR_NUMBER: ${{github.event.number}} + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v3 + with: + cache: 'yarn' + + - name: Install SDKs + run: "./scripts/fetch-develop.deps.sh --depth 1" + + - name: Install Dependencies + run: "yarn install" + + - name: Run Tests + run: "yarn test" diff --git a/scripts/package.sh b/scripts/package.sh index 9f95e87f1a..d43390cbc5 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -9,7 +9,7 @@ else fi yarn clean -VERSION=$version yarn build +VERSION=$version yarn build-stats # include the sample config in the tarball. Arguably this should be done by # `yarn build`, but it's just too painful.