From 11c1caed241406b9a4f8deba24b3e510b3744fb0 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Fri, 10 Apr 2026 14:41:59 -0300 Subject: [PATCH 1/4] ci: add e2e workflow to deploy plugin to Mattermost and verify it starts --- .github/workflows/e2e.yml | 132 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .github/workflows/e2e.yml diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 00000000..fb6b578e --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,132 @@ +name: e2e + +on: + push: + branches: + - master + pull_request: + +permissions: + contents: read + +jobs: + deploy-test: + name: Deploy and verify plugin + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: mmuser + POSTGRES_PASSWORD: mmuser_password + POSTGRES_DB: mattermost_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + env: + MM_SITEURL: http://localhost:8065 + MM_ADMIN_USERNAME: admin + MM_ADMIN_PASSWORD: Admin_1234! + PLUGIN_ID: com.mattermost.demo-plugin + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + cache-dependency-path: webapp/package-lock.json + + - name: Build plugin (linux-amd64) + env: + MM_SERVICESETTINGS_ENABLEDEVELOPER: true + run: make dist + + - name: Start Mattermost + run: | + docker run -d \ + --name mattermost \ + --network host \ + -e MM_SQLSETTINGS_DRIVERNAME=postgres \ + -e "MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mmuser_password@127.0.0.1:5432/mattermost_test?sslmode=disable&connect_timeout=10" \ + -e MM_SERVICESETTINGS_SITEURL=${{ env.MM_SITEURL }} \ + -e MM_SERVICESETTINGS_LISTENADDRESS=:8065 \ + -e MM_PLUGINSETTINGS_ENABLE=true \ + -e MM_PLUGINSETTINGS_ENABLEUPLOADS=true \ + -e MM_TEAMSETTINGS_ENABLEOPENSERVER=true \ + mattermost/mattermost-enterprise-edition:latest + + - name: Wait for Mattermost to be healthy + run: | + for i in $(seq 1 60); do + if curl -sf ${{ env.MM_SITEURL }}/api/v4/system/ping > /dev/null; then + echo "Mattermost is ready" + exit 0 + fi + echo "Waiting for Mattermost ($i/60)..." + sleep 5 + done + echo "Mattermost did not become healthy in time" + docker logs mattermost + exit 1 + + - name: Create admin user + run: | + docker exec mattermost /mattermost/bin/mattermost user create \ + --email admin@example.com \ + --username ${{ env.MM_ADMIN_USERNAME }} \ + --password ${{ env.MM_ADMIN_PASSWORD }} \ + --system_admin + + - name: Deploy plugin + env: + MM_SERVICESETTINGS_SITEURL: ${{ env.MM_SITEURL }} + MM_ADMIN_USERNAME: ${{ env.MM_ADMIN_USERNAME }} + MM_ADMIN_PASSWORD: ${{ env.MM_ADMIN_PASSWORD }} + run: | + BUNDLE=$(ls dist/*.tar.gz) + ./build/bin/pluginctl deploy ${{ env.PLUGIN_ID }} "$BUNDLE" + + - name: Verify plugin is active + run: | + TOKEN=$(curl -sf \ + -X POST ${{ env.MM_SITEURL }}/api/v4/users/login \ + -H 'Content-Type: application/json' \ + -d "{\"login_id\":\"$MM_ADMIN_USERNAME\",\"password\":\"$MM_ADMIN_PASSWORD\"}" \ + -D - | grep -i '^token:' | awk '{print $2}' | tr -d '\r\n') + + if [ -z "$TOKEN" ]; then + echo "Failed to obtain auth token" + exit 1 + fi + + PLUGINS=$(curl -sf \ + ${{ env.MM_SITEURL }}/api/v4/plugins \ + -H "Authorization: Bearer $TOKEN") + + echo "$PLUGINS" | python3 -c " + import json, sys + data = json.load(sys.stdin) + active_ids = [p['id'] for p in data.get('active', [])] + plugin_id = '${{ env.PLUGIN_ID }}' + if plugin_id not in active_ids: + print(f'Plugin {plugin_id} not found in active plugins: {active_ids}') + sys.exit(1) + print(f'Plugin {plugin_id} is active') + " + + - name: Show Mattermost logs on failure + if: failure() + run: docker logs mattermost From d3052a191c91a64b1b8438b626b2ebfee567cc3b Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Fri, 10 Apr 2026 14:44:50 -0300 Subject: [PATCH 2/4] ci: pin postgres service image to exact digest --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index fb6b578e..4b4f95c2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -16,7 +16,7 @@ jobs: services: postgres: - image: postgres:16-alpine + image: postgres:16-alpine@sha256:20edbde7749f822887a1a022ad526fde0a47d6b2be9a8364433605cf65099416 env: POSTGRES_USER: mmuser POSTGRES_PASSWORD: mmuser_password From c78ea5e1bc0e622a94098f9c42a3b598f95587ae Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Fri, 10 Apr 2026 14:47:35 -0300 Subject: [PATCH 3/4] ci: use mmctl to create admin user --- .github/workflows/e2e.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4b4f95c2..e1a6ef8f 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -84,11 +84,12 @@ jobs: - name: Create admin user run: | - docker exec mattermost /mattermost/bin/mattermost user create \ + docker exec mattermost /mattermost/bin/mmctl user create \ --email admin@example.com \ --username ${{ env.MM_ADMIN_USERNAME }} \ --password ${{ env.MM_ADMIN_PASSWORD }} \ - --system_admin + --system-admin \ + --local - name: Deploy plugin env: From d127ba569bf42ce16e92f287102acc806f1d38fd Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Fri, 10 Apr 2026 14:51:42 -0300 Subject: [PATCH 4/4] =?UTF-8?q?ci:=20fix=20plugin=20activation=20=E2=80=94?= =?UTF-8?q?=20enable=20required=20server=20settings=20and=20pre-configure?= =?UTF-8?q?=20plugin=20username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/e2e.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e1a6ef8f..61a5383b 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -63,6 +63,8 @@ jobs: -e "MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mmuser_password@127.0.0.1:5432/mattermost_test?sslmode=disable&connect_timeout=10" \ -e MM_SERVICESETTINGS_SITEURL=${{ env.MM_SITEURL }} \ -e MM_SERVICESETTINGS_LISTENADDRESS=:8065 \ + -e MM_SERVICESETTINGS_ENABLEGIFPICKER=true \ + -e MM_FILESETTINGS_ENABLEPUBLICLINK=true \ -e MM_PLUGINSETTINGS_ENABLE=true \ -e MM_PLUGINSETTINGS_ENABLEUPLOADS=true \ -e MM_TEAMSETTINGS_ENABLEOPENSERVER=true \ @@ -91,6 +93,29 @@ jobs: --system-admin \ --local + - name: Configure plugin settings + run: | + TOKEN=$(curl -sf \ + -X POST ${{ env.MM_SITEURL }}/api/v4/users/login \ + -H 'Content-Type: application/json' \ + -d "{\"login_id\":\"$MM_ADMIN_USERNAME\",\"password\":\"$MM_ADMIN_PASSWORD\"}" \ + -D - | grep -i '^token:' | awk '{print $2}' | tr -d '\r\n') + + curl -sf -X PUT ${{ env.MM_SITEURL }}/api/v4/config/patch \ + -H "Authorization: Bearer $TOKEN" \ + -H 'Content-Type: application/json' \ + -d '{ + "PluginSettings": { + "Plugins": { + "com.mattermost.demo-plugin": { + "username": "demouser", + "channelname": "demo", + "lastname": "User" + } + } + } + }' + - name: Deploy plugin env: MM_SERVICESETTINGS_SITEURL: ${{ env.MM_SITEURL }}