Skip to content

Commit

Permalink
Merge branch 'main' into chore/api-path
Browse files Browse the repository at this point in the history
  • Loading branch information
pfongkye authored Jul 18, 2024
2 parents 11f546a + f1a9884 commit 99c9351
Show file tree
Hide file tree
Showing 68 changed files with 3,634 additions and 35 deletions.
10 changes: 9 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
EMAIL_DOMAINS=my-domain.com,ext.my-domain.com
GITLAB_SECRET=GITLAB_SECRET
GITLAB_TOKEN=GITLAB_TOKEN
GITLAB_URL=https://my-git.domain.com
NODE_ENV=development
POSTGRES_HOST=0.0.0.0
POSTGRES_DATABASE_NAME=homer
POSTGRES_HOST=localhost
POSTGRES_PASSWORD=root
POSTGRES_PORT=54320
POSTGRES_USER=root
SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN=SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN
SLACK_SIGNING_SECRET=SLACK_SIGNING_SECRET
TICKET_MANAGEMENT_URL_PATTERN=https://my-ticket-management.com/view/{ticketId}
6 changes: 4 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@

API_BASE_PATH=/api/v1/homer
EMAIL_DOMAINS=my-domain.com,ext.my-domain.com
GITLAB_SECRET=GITLAB_SECRET
GITLAB_TOKEN=GITLAB_TOKEN
GITLAB_URL=https://my-git.domain.com
NODE_ENV=test
POSTGRES_DATABASE_NAME=homer
POSTGRES_HOST=localhost
POSTGRES_PASSWORD=root
POSTGRES_PORT=54320
POSTGRES_USER=root
SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN=SLACK_BOT_USER_O_AUTH_ACCESS_TOKEN
SLACK_SIGNING_SECRET=SLACK_SIGNING_SECRET
EMAIL_DOMAINS=my-domain.com,ext.my-domain.com
GITLAB_URL=https://my-git.domain.com
TICKET_MANAGEMENT_URL_PATTERN=https://my-ticket-management.com/view/{ticketId}
19 changes: 18 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
name: dist
path: dist

- name: Upload node_modules
uses: actions/upload-artifact@v4
with:
name: node_modules
path: node_modules

docker:
name: Build Docker Image and publish to Github Artifact Registry
needs: build
Expand All @@ -40,12 +46,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: ↙️ Download build artifact
- name: ↙️ Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: dist

- name: ↙️ Download node_modules
uses: actions/download-artifact@v4
with:
name: node_modules
path: node_modules

- uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
Expand All @@ -63,7 +77,10 @@ jobs:
id: build-and-push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ EXPOSE 3000

USER node

COPY --chown=node:node package.json /home/node/app/package.json
COPY --chown=node:node yarn.lock /home/node/app/yarn.lock
COPY --chown=node:node dist /home/node/app/dist

RUN yarn install
COPY --chown=node:node node_modules /home/node/app/node_modules

CMD ["node", "dist/src/index.js"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Here are the available commands:
| `/homer project add <project_name\|project_id>` | Add a Gitlab project to a channel. |
| `/homer project list` | List the Gitlab projects added to a channel. |
| `/homer project remove` | Remove a Gitlab project from a channel. |
| `/homer release` | Create a release for configured Gitlab project in a channel. |
| `/homer review <search>` | Share a merge request on a channel.<br />Searches in title and description by default.<br />Accepts merge request URLs and merge request IDs prefixed with "!". |
| `/homer review list` | List ongoing reviews shared in a channel. |

Expand Down Expand Up @@ -226,6 +227,7 @@ Create a `.env` file containing the following variables:
If you want Homer to connect to an **external PostgreSQL database**, you can set
the following variables:

- `POSTGRES_DATABASE_NAME`: database name (like `homer`).
- `POSTGRES_HOST`: host of the database.
- `POSTGRES_PASSWORD`: password used when connecting to the database.
- `POSTGRES_PORT`: port where the database listens.
Expand Down
79 changes: 79 additions & 0 deletions __tests__/__fixtures__/deploymentFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import type { GitlabDeployment } from '@/core/typings/GitlabDeployment';
import { pipelineFixture } from './pipelineFixture';
import { tagFixture } from './tagFixture';

export const deploymentFixture: GitlabDeployment = {
id: 42,
iid: 2,
ref: tagFixture.name,
sha: tagFixture.commit.id,
created_at: '2016-08-11T11:32:35.444Z',
updated_at: '2016-08-11T11:34:01.123Z',
status: 'success',
user: {
name: 'Administrator',
username: 'root',
id: 1,
state: 'active',
avatar_url:
'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
web_url: 'http://localhost:3000/root',
},
environment: {
id: 9,
name: 'production',
external_url: 'https://about.gitlab.com',
},
deployable: {
id: 664,
status: 'success',
stage: 'deploy',
name: 'deploy',
ref: 'main',
tag: false,
coverage: null,
created_at: '2016-08-11T11:32:24.456Z',
started_at: null,
finished_at: '2016-08-11T11:32:35.145Z',
project: {
ci_job_token_scope_enabled: false,
},
user: {
id: 1,
name: 'Administrator',
username: 'root',
state: 'active',
avatar_url:
'http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
web_url: 'http://gitlab.dev/root',
created_at: '2015-12-21T13:14:24.077Z',
bio: null,
location: null,
skype: '',
linkedin: '',
twitter: '',
website_url: '',
organization: '',
},
commit: {
id: 'a91957a858320c0e17f3a0eca7cfacbff50ea29a',
short_id: 'a91957a8',
title: "Merge branch 'rename-readme' into 'main'\r",
author_name: 'Administrator',
author_email: '[email protected]',
created_at: '2016-08-11T13:28:26.000+02:00',
message:
"Merge branch 'rename-readme' into 'main'\r\n\r\nRename README\r\n\r\n\r\n\r\nSee merge request !2",
},
pipeline: {
...pipelineFixture,
created_at: '2016-08-11T07:43:52.143Z',
ref: tagFixture.name,
sha: tagFixture.commit.id,
status: 'success',
updated_at: '2016-08-11T07:43:52.143Z',
web_url: 'https://example.com/foo/bar/pipelines/61',
},
runner: null,
},
};
35 changes: 35 additions & 0 deletions __tests__/__fixtures__/dockerBuildJobFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { GitlabJob } from '@/core/typings/GitlabJob';
import { pipelineFixture } from './pipelineFixture';
import { userDetailsFixture } from './userDetailsFixture';

export const dockerBuildJobFixture: GitlabJob = {
commit: {
author_email: '[email protected]',
author_name: 'Administrator',
created_at: '2015-12-24T16:51:14.000+01:00',
id: '0ff3ae198f8601a285adcf5c0fff204ee6fba5fd',
message: 'Test the CI integration.',
short_id: '0ff3ae19',
title: 'Test the CI integration.',
},
coverage: null,
allow_failure: false,
created_at: '2015-12-24T15:51:21.802Z',
started_at: '2015-12-24T17:54:27.722Z',
finished_at: '2015-12-24T17:54:27.895Z',
duration: 0.173,
queued_duration: 0.01,
artifacts: [],
artifacts_expire_at: '2016-01-23T17:54:27.895Z',
tag_list: ['docker runner', 'ubuntu18'],
id: 7,
name: 'build_image',
pipeline: pipelineFixture,
ref: 'main',
runner: null,
stage: 'test',
status: 'success',
tag: false,
web_url: 'https://example.com/foo/bar/-/jobs/7',
user: userDetailsFixture,
};
45 changes: 45 additions & 0 deletions __tests__/__fixtures__/hooks/deploymentHookFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { GitlabDeploymentHook } from '@/core/typings/GitlabDeploymentHook';
import { deploymentFixture } from '../deploymentFixture';
import { projectFixture } from '../projectFixture';

export const deploymentHookFixture: GitlabDeploymentHook = {
object_kind: 'deployment',
status: 'success',
status_changed_at: '2021-04-28 21:50:00 +0200',
deployment_id: deploymentFixture.id,
deployable_id: 796,
deployable_url:
'http://10.126.0.2:3000/root/diaspora-project-site/-/jobs/796',
environment: 'staging',
project: {
id: projectFixture.id,
name: 'diaspora-project-site',
description: '',
web_url: 'http://example.com/diaspora/diaspora-project-site',
avatar_url: null,
git_ssh_url: 'ssh://[email protected]:2222/root/diaspora-project-site.git',
git_http_url: 'http://example.com/diaspora/diaspora-project-site.git',
namespace: 'Administrator',
visibility_level: 0,
path_with_namespace: 'root/diaspora-project-site',
default_branch: 'master',
ci_config_path: '',
homepage: 'http://example.com/diaspora/diaspora-project-site',
url: 'ssh://[email protected]/diaspora/diaspora-project-site.git',
ssh_url: 'ssh://[email protected]/diaspora/diaspora-project-site.git',
http_url: 'http://example.com/diaspora/diaspora-project-site.git',
},
short_sha: '279484c0',
user: {
id: 1,
name: 'Administrator',
username: 'root',
avatar_url:
'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
email: '[email protected]',
},
user_url: 'http://10.126.0.2:3000/root',
commit_url:
'http://example.com/diaspora/diaspora-project-site/-/commit/279484c09fbe69ededfced8c1bb6e6d24616b468',
commit_title: 'Add new file',
};
73 changes: 73 additions & 0 deletions __tests__/__fixtures__/hooks/pushHookFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,76 @@ export const pushHookFixture = {
],
total_commits_count: 4,
};

export const pushHookFixtureFeatureBranch = {
object_kind: 'push',
before: '95790bf891e76fee5e1747ab589903a6a1f80f22',
after: 'da1560886d4f094c3e6c9ef40349f7d38b5d27d7',
ref: 'refs/heads/feat/add-logo',
checkout_sha: 'da1560886d4f094c3e6c9ef40349f7d38b5d27d7',
user_id: 4,
user_name: 'John Smith',
user_username: 'jsmith',
user_email: '[email protected]',
user_avatar:
'https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80',
project_id: projectFixture.id,
project: {
id: projectFixture.id,
name: projectFixture.name,
description: projectFixture.description,
web_url: projectFixture.web_url,
avatar_url: projectFixture.avatar_url,
git_ssh_url: '[email protected]:mike/diaspora.git',
git_http_url: 'http://example.com/mike/diaspora.git',
namespace: projectFixture.namespace,
visibility_level: 0,
path_with_namespace: projectFixture.path_with_namespace,
default_branch: projectFixture.default_branch,
homepage: 'http://example.com/mike/diaspora',
url: '[email protected]:mike/diaspora.git',
ssh_url: '[email protected]:mike/diaspora.git',
http_url: 'http://example.com/mike/diaspora.git',
},
repository: {
name: 'Diaspora',
url: '[email protected]:mike/diaspora.git',
description: '',
homepage: 'http://example.com/mike/diaspora',
git_http_url: 'http://example.com/mike/diaspora.git',
git_ssh_url: '[email protected]:mike/diaspora.git',
visibility_level: 0,
},
commits: [
{
id: 'b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327',
message:
'Update Catalan translation to e38cb41.\n\nSee https://gitlab.com/gitlab-org/gitlab for more information',
title: 'Update Catalan translation to e38cb41.',
timestamp: '2011-12-12T14:27:31+02:00',
url: 'http://example.com/mike/diaspora/commit/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327',
author: {
name: 'Jordi Mallach',
email: '[email protected]',
},
added: ['CHANGELOG'],
modified: ['app/controller/application.rb'],
removed: [],
},
{
id: 'da1560886d4f094c3e6c9ef40349f7d38b5d27d7',
message: 'fixed readme',
title: 'fixed readme',
timestamp: '2012-01-03T23:36:29+02:00',
url: 'http://example.com/mike/diaspora/commit/da1560886d4f094c3e6c9ef40349f7d38b5d27d7',
author: {
name: 'GitLab dev user',
email: 'gitlabdev@dv6700.(none)',
},
added: ['CHANGELOG'],
modified: ['app/controller/application.rb'],
removed: [],
},
],
total_commits_count: 4,
};
39 changes: 39 additions & 0 deletions __tests__/__fixtures__/jobFixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { GitlabJob } from '@/core/typings/GitlabJob';
import type { GitlabPipeline } from '@/core/typings/GitlabPipeline';
import { bridgeFixture } from './bridgeFixture';
import { userDetailsFixture } from './userDetailsFixture';

export const jobFixture: GitlabJob = {
commit: {
author_email: '[email protected]',
author_name: 'Administrator',
created_at: '2015-12-24T16:51:14.000+01:00',
id: '0ff3ae198f8601a285adcf5c0fff204ee6fba5fd',
message: 'Test the CI integration.',
short_id: '0ff3ae19',
title: 'Test the CI integration.',
},
coverage: null,
allow_failure: false,
created_at: '2015-12-24T15:51:21.802Z',
started_at: '2015-12-24T17:54:27.722Z',
finished_at: '2015-12-24T17:54:27.895Z',
duration: 0.173,
queued_duration: 0.01,
artifacts: [],
artifacts_expire_at: '2016-01-23T17:54:27.895Z',
tag_list: ['docker runner', 'ubuntu18'],
id: 7,
name: 'chat',
pipeline: {
...bridgeFixture.downstream_pipeline,
project_id: 12,
} as GitlabPipeline,
ref: 'main',
runner: null,
stage: 'test',
status: 'success',
tag: false,
web_url: 'https://example.com/foo/bar/-/jobs/7',
user: userDetailsFixture,
};
Loading

0 comments on commit 99c9351

Please sign in to comment.