-
Notifications
You must be signed in to change notification settings - Fork 108
ci: add e2e workflow to deploy plugin to Mattermost and verify it starts #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+158
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
11c1cae
ci: add e2e workflow to deploy plugin to Mattermost and verify it starts
lieut-data d3052a1
ci: pin postgres service image to exact digest
lieut-data c78ea5e
ci: use mmctl to create admin user
lieut-data d127ba5
ci: fix plugin activation — enable required server settings and pre-c…
lieut-data File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| 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@sha256:20edbde7749f822887a1a022ad526fde0a47d6b2be9a8364433605cf65099416 | ||
| 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_SERVICESETTINGS_ENABLEGIFPICKER=true \ | ||
| -e MM_FILESETTINGS_ENABLEPUBLICLINK=true \ | ||
| -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/mmctl user create \ | ||
| --email admin@example.com \ | ||
| --username ${{ env.MM_ADMIN_USERNAME }} \ | ||
| --password ${{ env.MM_ADMIN_PASSWORD }} \ | ||
| --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 }} | ||
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.