Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

cherry pickCherry pick of #24375 #925

cherry pickCherry pick of #24375

cherry pickCherry pick of #24375 #925

Workflow file for this run

name: ci
on:
pull_request:
push:
branches:
- master
- release-7.8
defaults:
run:
shell: bash
jobs:
check-lint:
runs-on: ubuntu-22.04
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
id: setup_node
with:
node-version-file: ".nvmrc"
cache: npm
- name: ci/get-node-modules
run: |
make node_modules
make e2e/playwright/node_modules
- name: ci/lint
run: |
npm run check
check-i18n:
runs-on: ubuntu-22.04
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
id: setup_node
with:
node-version-file: ".nvmrc"
cache: npm
- name: ci/get-node-modules
run: |
make node_modules
make e2e/playwright/node_modules
- name: ci/lint
run: |
cp i18n/en.json /tmp/en.json
mkdir -p /tmp/fake-mobile-dir/assets/base/i18n/
echo '{}' > /tmp/fake-mobile-dir/assets/base/i18n/en.json
npm run mmjstool -- i18n extract-webapp --webapp-dir . --mobile-dir /tmp/fake-mobile-dir
diff /tmp/en.json i18n/en.json
# Address weblate behavior which does not remove whole translation item when translation string is set to empty
npm run mmjstool -- i18n clean-empty --webapp-dir . --mobile-dir /tmp/fake-mobile-dir --check
npm run mmjstool -- i18n check-empty-src --webapp-dir . --mobile-dir /tmp/fake-mobile-dir
rm -rf tmp
check-type:
runs-on: ubuntu-22.04
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
id: setup_node
with:
node-version-file: ".nvmrc"
cache: npm
- name: ci/get-node-modules
run: |
make node_modules
make e2e/playwright/node_modules
- name: ci/lint
run: |
npm run check-types
tests:
runs-on: ubuntu-22.04
needs: [check-type, check-i18n, check-lint]
permissions:
checks: write
pull-requests: write
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
id: setup_node
with:
node-version-file: ".nvmrc"
cache: npm
- name: ci/get-node-modules
run: |
make node_modules
make e2e/playwright/node_modules
- name: ci/detect-cpu-core
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@c508d404ab007faae80a014072fd8c0e17792118 # v1.1.0
- name: ci/test
run: |
npm run test-ci -- --maxWorkers=${{ steps.cpu-cores.outputs.count }}
- name: ci/publish-test-results
uses: EnricoMi/publish-unit-test-result-action@a3caf02865c0604ad3dc1ecfcc5cdec9c41b7936 # v2.3.0
if: always()
with:
junit_files: "build/**/*.xml"
comment_mode: always
compare_to_earlier_commit: false
build:
runs-on: ubuntu-22.04
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
id: setup_node
with:
node-version-file: ".nvmrc"
cache: npm
- name: ci/get-node-modules
run: |
make node_modules
make e2e/playwright/node_modules
- name: ci/build
run: |
node --version
npm version
make dist
- name: ci/persist-artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: webapp-artifact
path: mattermost-webapp.tar.gz
retention-days: 14
upload-s3:
runs-on: ubuntu-22.04
needs: build
env:
REPO_NAME: ${{ github.event.repository.name }}
steps:
- name: ci/artifacts-downloads
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b # v3.0.2
with:
name: webapp-artifact
- name: ci/aws-configure
uses: aws-actions/configure-aws-credentials@07c2f971bac433df982ccc261983ae443861db49 # v1-node16
with:
aws-region: ${{ secrets.WEBAPP_AWS_REGION }}
aws-access-key-id: ${{ secrets.WEBAPP_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WEBAPP_AWS_SECRET_ACCESS_KEY }}
# We need to sanitize the branch name before using it
- name: ci/sanitize-branch-name
id: branch
uses: transferwise/sanitize-branch-name@b10b4d524ac5a7b645b43a3527db3a6cca017b9d # v1
# Search for the string "pull" and replace it with "PR" in branch-name
- name: ci/sanitize-branch-name-replace-pull-with-PR-
run: echo "BRANCH_NAME=$(echo ${{ steps.branch.outputs.sanitized-branch-name }} | sed 's/^pull\//PR-/g')" >> $GITHUB_ENV
- name: ci/artifact-upload
run: |
aws s3 cp mattermost-webapp.tar.gz s3://${{secrets.AWS_S3_BUCKET_PRS}}/$REPO_NAME/$BRANCH_NAME/ --cache-control no-cache
aws s3 cp mattermost-webapp.tar.gz s3://${{secrets.AWS_S3_BUCKET_PRS}}/$REPO_NAME/commit/${{ github.sha }}/ --cache-control no-cache
prepare-docker-build:
runs-on: ubuntu-22.04
needs: upload-s3
# Run this Job, on every branch except "master","cloud-*","release-*" branches
if: |
${{ !(github.ref_name == 'master' ||
github.ref_name == 'cloud' ||
startsWith(github.ref_name,'release-'))
}}
env:
REPO_NAME: ${{ github.event.repository.name }}
steps:
- name: ci/checkout-repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
# We need to sanitize the branch name before using it
- name: ci/sanitize-branch-name
id: branch
uses: transferwise/sanitize-branch-name@b10b4d524ac5a7b645b43a3527db3a6cca017b9d # v1
# Search for the string "pull" and replace it with "PR" in branch-name
- name: ci/sanitize-branch-name-replace-pull-with-PR-
run: echo "BRANCH_NAME=$(echo ${{ steps.branch.outputs.sanitized-branch-name }} | sed 's/^pull\//PR-/g')" >> $GITHUB_ENV
- name: ci/artifacts-downloads
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b # v3.0.2
with:
name: webapp-artifact
- name: ci/Download-server-bundle
run: |
curl -f -o server.tar.gz https://pr-builds.mattermost.com/mattermost-server/$BRANCH_NAME/mattermost-enterprise-linux-amd64.tar.gz || true
if [[ -f server.tar.gz ]]; then
echo "Downloaded server bundle for $BRANCH_NAME branch from pr-builds.mattermost.com"
else
curl -f -o server.tar.gz https://s3.amazonaws.com/releases.mattermost.com/gitlab/bundle/release-7.8/mattermost-enterprise-linux-amd64.tar.gz
echo "Downloaded server bundle for release-7.8 from releases.mattermost.com"
fi
tar xf server.tar.gz
- name: ci/Replace-web-app
run: |
mv mattermost/client client-original
tar xf mattermost-webapp.tar.gz
mv client mattermost/client
- name: ci/Re-add-products
run: |
mv client-original/products mattermost/client/products
- name: ci/Repackage server bundle
run: |
tar -zcf mattermost-enterprise-linux-amd64.tar.gz mattermost/
- name: ci/persist-artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: mattermost-enterprise-linux-artifact
path: mattermost-enterprise-linux-amd64.tar.gz
retention-days: 14
- name: ci/aws-configure
uses: aws-actions/configure-aws-credentials@07c2f971bac433df982ccc261983ae443861db49 # v1-node16
with:
aws-region: ${{ secrets.WEBAPP_AWS_REGION }}
aws-access-key-id: ${{ secrets.WEBAPP_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WEBAPP_AWS_SECRET_ACCESS_KEY }}
- name: ci/artifact-upload
run: |
aws s3 cp mattermost-enterprise-linux-amd64.tar.gz s3://${{secrets.AWS_S3_BUCKET_PRS}}/$REPO_NAME/commit/${{ github.event.pull_request.head.sha || github.sha }}/ --cache-control no-cache
build-docker:
runs-on: ubuntu-22.04
needs: prepare-docker-build
steps:
- name: cd/configure-env-variables
id: vars
# Extract short-sha as TAG, and repository name as REPO_NAME
run: |
echo "TAG=`echo ${{ github.event.pull_request.head.sha || github.sha }} | cut -c1-7`" >> $GITHUB_ENV
echo "REPO_NAME=${{github.event.repository.name}}" >> $GITHUB_ENV
- name: cd/Login to Docker Hub
uses: docker/login-action@3da7dc6e2b31f99ef2cb9fb4c50fb0971e0d0139 # v2.1.0
with:
username: ${{ secrets.DOCKERHUB_DEV_USERNAME }}
password: ${{ secrets.DOCKERHUB_DEV_TOKEN }}
- name: cd/Setup Docker Buildx
uses: docker/setup-buildx-action@11e8a2e2910826a92412015c515187a2d6750279 # v2.4
- name: cd/docker-build-push
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
wget https://raw.githubusercontent.com/mattermost/mattermost-server/release-7.8/build/Dockerfile
wget https://raw.githubusercontent.com/mattermost/mattermost-server/release-7.8/build/entrypoint.sh
chmod +x entrypoint.sh
export MM_PACKAGE=https://pr-builds.mattermost.com/$REPO_NAME/commit/${{ github.event.pull_request.head.sha || github.sha }}/mattermost-enterprise-linux-amd64.tar.gz
docker buildx build --push --build-arg MM_PACKAGE=$MM_PACKAGE -t mattermostdevelopment/mm-ee-test:${TAG} --provenance=false .