Skip to content

Commit

Permalink
Merge branch 'master' into issue-669
Browse files Browse the repository at this point in the history
  • Loading branch information
thoratvinod authored Dec 3, 2023
2 parents 240b7ee + 8cf783f commit 3c5d9cd
Show file tree
Hide file tree
Showing 60 changed files with 4,541 additions and 1,080 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/issue_add.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: issue_add

on:
issues:
types:
- opened

permissions:
repository-projects: write

jobs:
add-to-project:
if: ${{ github.repository_owner == 'mattermost' }}
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: mattermost/github-app-installation-token-action@181cd1b8c94b158428c4facfe043d6e28c20be55
id: ghapp
with:
appId: "${{ vars.UNIFIED_CI_APP_ID }}"
installationId: "${{ vars.UNIFIED_CI_INSTALLATION_ID }}"
privateKey: ${{ secrets.UNIFIED_CI_PRIVATE_KEY }}
- uses: actions/add-to-project@31b3f3ccdc584546fc445612dec3f38ff5edb41c #v0.5.0
with:
project-url: https://github.com/orgs/mattermost/projects/9
github-token: ${{ steps.ghapp.outputs.token }}
23 changes: 16 additions & 7 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Playwright Tests
on:
schedule:
- cron: "0 0 * * *"
pull_request:
push:
branches:
- master
workflow_run:
workflows: ["ci"]
types:
- completed

env:
TERM: xterm
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
ports:
- 9200:9200
mattermost-server:
image: mattermost/mattermost-enterprise-edition:release-7.7
image: mattermost/mattermost-enterprise-edition:master
env:
DB_HOST: postgres
DB_PORT_NUMBER: 5432
Expand Down Expand Up @@ -126,6 +126,7 @@ jobs:
run: make deploy
env:
PLUGIN_E2E_MOCK_OAUTH_SERVER_URL: http://172.17.0.1:8080
E2E_TESTING: true

- name: ci/setup-node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
Expand All @@ -139,6 +140,16 @@ jobs:
cd e2e/playwright
./setup-environment
- name: ci/tsc
run: |
cd e2e/playwright
npm run tsc
- name: ci/lint
run: |
cd e2e/playwright
npm run lint
- name: ci/run-playwright-tests
run: |
cd e2e/playwright
Expand All @@ -152,8 +163,6 @@ jobs:
run: |
cd e2e/playwright
mkdir results
mv screenshots results
mv playwright-report results
- uses: actions/upload-artifact@v3
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ GitHub plugin configuration starts by registering an OAuth app in GitHub and end

**Note:** If you're using GitHub Enterprise, replace all GitHub links below with your GitHub Enterprise URL.

You can use the `/github setup` command to streamline the configuration process.

### Step 1: Register an OAuth Application in GitHub

You must first register the Mattermost GitHub Plugin as an authorized OAuth app regardless of whether you're setting up the GitHub plugin as a system admin or a Mattermost user.
Expand Down Expand Up @@ -140,7 +142,7 @@ When you’ve tested the plugin and confirmed it’s working, notify your team s
## Slash Commands

* __Autocomplete slash commands__ - Explore all the available slash commands by typing `/` in the text input box - the autocomplete suggestions help by providing a format example in black text and a short description of the slash command in grey text. Visit the [executing commands](https://docs.mattermost.com/help/messaging/executing-commands.html) documentation for more details.
* __Autocomplete slash commands__ - Explore all the available slash commands by typing `/` in the text input box - the autocomplete suggestions help by providing a format example in black text and a short description of the slash command in grey text. Visit the [documentation](https://docs.mattermost.com/channels/run-slash-commands.html) for more details.
* __Subscribe to a repository__ - Use `/github subscriptions add` to subscribe a Mattermost channel to receive notifications for new pull requests, issues, branch creation, and more in a GitHub repository.

- For instance, to post notifications for issues, issue comments, and pull requests matching the label `Help Wanted` from `mattermost/mattermost-server`, use:
Expand All @@ -152,9 +154,14 @@ When you’ve tested the plugin and confirmed it’s working, notify your team s
- `--exclude-org-member`: events triggered by organization members will not be delivered. It will be locked to the organization provided in the plugin configuration and it will only work for users whose membership is public. Note that organization members and collaborators are not the same.
- `--render-style`: notifications will be delivered in the specified style (for example, the body of a pull request will not be displayed). Supported
values are `collapsed`, `skip-body` or `default` (same as omitting the flag).

- `--exclude`: comma-separated list of the repositories to exclude from getting the subscription notifications like `mattermost/mattermost-server`. Only supported for subscriptions to an organization.

* __Get to do items__ - Use `/github todo` to get an ephemeral message with items to do in GitHub, including a list of unread messages and pull requests awaiting your review.
* __Update settings__ - Use `/github settings` to update your settings for notifications and daily reminders.
* __Setup GitHub integration__ - Use `/github setup` to configure the integration between GitHub and Mattermost. This command has the following subcommands:
- `/github setup oauth`: Sets up the OAuth2 application in GitHub, establishing the necessary authorization connection between GitHub and Mattermost.
- `/github setup webhook`: Creates a webhook from GitHub to Mattermost, allowing real-time notifications and updates from GitHub to be sent to Mattermost channels.
- `/github setup announce`: Sends a message to designated channels in Mattermost, announcing the availability of the GitHub integration for team members to use.
* __And more!__ - Run `/github help` to see what else the slash command can do.

## Frequently Asked Questions
Expand Down
5 changes: 4 additions & 1 deletion build/custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ endif
GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost-plugin-api/experimental/telemetry.rudderWriteKey=$(RUDDER_WRITE_KEY)"'

ifdef PLUGIN_E2E_MOCK_OAUTH_SERVER_URL
GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost-plugin-github/server/plugin.testOAuthServerURL=$(PLUGIN_E2E_MOCK_OAUTH_SERVER_URL)"'
GO_BUILD_FLAGS += -ldflags '-X "github.com/mattermost/mattermost-plugin-github/server/plugin.testOAuthServerURL=$(PLUGIN_E2E_MOCK_OAUTH_SERVER_URL)"'
endif
.PHONY: deploy-e2e
deploy-e2e: dist
E2E_TESTING=true PLUGIN_E2E_MOCK_OAUTH_SERVER_URL=http://localhost:8080 ./build/bin/pluginctl deploy $(PLUGIN_ID) dist/$(BUNDLE_NAME)
2 changes: 2 additions & 0 deletions build/setup.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
GO_BUILD_FLAGS ?=

# Ensure that go is installed. Note that this is independent of whether or not a server is being
# built, since the build script itself uses go.
ifeq ($(GO),)
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions e2e/playwright/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": [
"../../webapp/.eslintrc.json"
],
"overrides": [
{
"files": ["**/*.ts"],
"plugins": ["import"],
"parser": "@typescript-eslint/parser",
"rules": {
"import/no-unresolved": "off",
"max-nested-callbacks": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
}
}
]
}
2 changes: 2 additions & 0 deletions e2e/playwright/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
screenshots
playwright-report
test-results
.auth-user.json
.eslintcache
2 changes: 1 addition & 1 deletion e2e/playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ What this script does:
- Install Playwright test dependencies - `cd ../e2e-tests/playwright && npm i`
- Install Playwright - `npx install playwright`
- Install GitHub plugin e2e dependencies - `cd ../../../mattermost-plugin-github/e2e/playwright && npm i`
- Build and deploy plugin with mock OAuth server URL env var - `PLUGIN_E2E_MOCK_OAUTH_SERVER_URL=http://localhost:8080 make deploy`
- Build and deploy plugin with e2e support - `make deploy-e2e`

-----

Expand Down
5 changes: 5 additions & 0 deletions e2e/playwright/mock_oauth_server/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# export MOCK_OAUTH_ACCESS_TOKEN=

# export MM_SERVICESETTINGS_SITEURL=
# export MM_PLUGIN_ID=
# export OAUTH_SERVER_PORT=
28 changes: 0 additions & 28 deletions e2e/playwright/mock_oauth_server/index.ts

This file was deleted.

9 changes: 5 additions & 4 deletions e2e/playwright/mock_oauth_server/mock_oauth_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const makeOAuthServer = ({
expiryAlgorithm,
}: OAuthServerOptions): express.Express => {
if (!mockOAuthAccessToken) {
throw new Error(`MockOAuthServer: Please provide an OAuth access token to use`);
throw new Error('MockOAuthServer: Please provide an OAuth access token to use');
}

if (expiryAlgorithm !== ExpiryAlgorithms.NO_EXPIRY) {
Expand All @@ -29,14 +29,15 @@ export const makeOAuthServer = ({

const app = express();

// eslint-disable-next-line new-cap
const oauthRouter = express.Router();

oauthRouter.get('/authorize', function (req, res) {
oauthRouter.get('/authorize', (req, res) => {
const query = req.url.split('?')[1];
res.redirect(`${mattermostSiteURL}/plugins/${pluginId}/oauth/complete?${query}&code=1234`);
});

oauthRouter.post('/access_token', function (req, res) {
oauthRouter.post('/access_token', (req, res) => {
const token = {
access_token: mockOAuthAccessToken,
token_type: 'bearer',
Expand All @@ -49,4 +50,4 @@ export const makeOAuthServer = ({
app.use(authorizeURLPrefix, oauthRouter);

return app;
}
};
Loading

0 comments on commit 3c5d9cd

Please sign in to comment.