Skip to content
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

gitlab throttling + adaptation to gitlab api changes + more logging for troubleshooting #256

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 32 additions & 88 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,44 @@
name: Build and Release
# This workflow uses actions that are not certified by GitHub.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file.

# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image

on:
push:
tags:
- 'v*'
branches: [ master ]
pull_request:
branches: [ master ]
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Install grunt-cli
run: npm install -g grunt-cli

- name: Install local dependencies
run: npm install

- name: Run CI build
run: npm run-script ci

release:
if: startsWith(github.ref, 'refs/tags/')
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Install global dependencies
run: |
npm install -g grunt-cli
npm install -g pkg

- name: Install local dependencies
run: npm install

- name: Build Release Package
run: npm run-script pkg
- name: Check out the repo
uses: actions/checkout@v3

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Upload Release Asset (Linux)
id: upload-release-asset-linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release/node-build-monitor-linux
asset_name: node-build-monitor-linux
asset_content_type: application/octet-stream
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Upload Release Asset (Mac OS)
id: upload-release-asset-macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release/node-build-monitor-macos
asset_name: node-build-monitor-macos
asset_content_type: application/octet-stream

- name: Upload Release Asset (Windows)
id: upload-release-asset-windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
images: |
yaman/node-build-monitor

- name: Build and push Docker images
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release/node-build-monitor-win.exe
asset_name: node-build-monitor-win.exe
asset_content_type: application/octet-stream
context: .
push: true
tags: yaman/node-build-monitor:latest
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ ONBUILD ADD config.json /build-mon/app/config.json

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file.

EXPOSE 3000

CMD [ "forever","--watch", "--watchDirectory", "/build-mon/app", "/build-mon/app/app.js"]
CMD [ "forever","--watch", "--watchDirectory", "/build-mon/app", "/build-mon/app/app.js"]
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,11 @@ Supports an on-premise [GitLab](http://gitlab.com) Community Edition/Enterprise
{
"name": "GitLab",
"configuration": {
"debug": false,
"url": "http://gitlab.example.com:8080",
"token": "secret_user_token",
"additional_query": "&search=gitlab-org&starred=true",
"main_group" : "your_main_project_group",
"numberOfPipelinesPerProject": 3,
"pipeline": {
"status": ["running", "pending", "success", "failed", "canceled", "skipped"]
Expand All @@ -338,11 +340,13 @@ Supports an on-premise [GitLab](http://gitlab.com) Community Edition/Enterprise

| Setting | Description
|--------------------|-------------------------------------------------------------------------------------------------------------
| `url` | GitLab server http(s) address string
| `token` | Secret token string for the existing user to be used to authenticate against GitLab REST API
| `slugs` | List of project slugs to display and check for builds. Defaults to `*/*` for all projects you have access to. Use `/*` when specifying group slug to include projects only from current group and `/**` to also include subgroups. Optional 'ref' attribute can be used to specify the branch.
| `debug` | Print all available logs to console.
| `url` | GitLab server http(s) address string.
| `token` | Secret token string for the existing user to be used to authenticate against GitLab REST API.
| `slugs` | List of project slugs to display and check for builds. Defaults to `*/*` for all projects you have .access to. Use `/*` when specifying group slug to include projects only from current group and `/**` to also include subgroups. Optional 'ref' attribute can be used to specify the branch.
| `intervals` | How often (in integer of milliseconds) ...
| `additional_query` | Add [additional query parameters](https://gitlab.com/help/api/projects.md) so not too many projects are fetched.
| `main_group` | Gitlab needs a main group to analyze the project only you want to monitor, otherwise, you will get the whole world.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens, if this property is not set? Will existing GitLab configurations crash after an upgrade of the build monitor?

| `numberOfPipelinesPerProject` | Limit the number of pipelines fetched for each project. Optional, defaults to no limitation.

Because API V4 returns **all** internal and public projects by default, you propably
Expand Down
4 changes: 4 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ monitor.run();

// helpers
function tryExpandEnvironmentVariables(monitorConfiguration, serviceConfiguration) {
if (process.env.TOKEN) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change. This should happen automatically by tryExpandEnvironmentVariable, if expandEnvironmentVariables is set to true.

serviceConfiguration.token = process.env.TOKEN;
}

if (monitorConfiguration.expandEnvironmentVariables) {
for (var property in serviceConfiguration) {
serviceConfiguration[property] = tryExpandEnvironmentVariable(serviceConfiguration[property]);
Expand Down
2 changes: 1 addition & 1 deletion app/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all changes in this file.

}
]
}
}
Loading