Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.
Merged
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
23 changes: 14 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# The ID of your GitHub App
APP_ID=
APP_ID=12345

# The webhook secret for GitHub
WEBHOOK_SECRET=development

# The name of your bot
BOT_NAME=Rally

# Set the NODE_ENV
# NODE_ENV=production
NODE_ENV=production

# Uncomment this to get verbose logging; use `info` to show less
# LOG_LEVEL=trace
LOG_LEVEL=info

# Go to https://smee.io/new set this to the URL that you are redirected to.
# WEBHOOK_PROXY_URL=

# Uncomment the following line and use your own GitHub Enterprise
# instance if this will not be used on https://github.com
# GHE_HOST=github.example.com
GHE_HOST=github.example.com

# This setting should ONLY be used for testing with
# a self-signed certificate or when a proxy is causing certificate issues
# NODE_TLS_REJECT_UNAUTHORIZED=0

# Create a private key in your organization and reference the path here
PRIVATE_KEY_PATH=/opt/rally/.ssh/rally.pem
PRIVATE_KEY_PATH=.ssh/rally.pem

#############################
# Rally connection settings #
Expand All @@ -35,13 +40,13 @@ RALLY_SERVER=https://rally1.rallydev.com
# NOTE: This is not required if you are using an API key,
# which is the preferred method
# Example: RALLY_USERNAME=rallyuser
RALLY_USERNAME=
#RALLY_USERNAME=

# Password to connect and access all Rally information
# NOTE: This is not required if you are using an API key,
# which is the preferred method
# Example: RALLY_PASSWORD=Som3C0olP@ssword!
RALLY_PASSWORD=
#RALLY_PASSWORD=

# API Key for connecting to Rally
# Example: RALLY_API_KEY=123abCD...
Expand All @@ -61,6 +66,6 @@ ENFORCE_ALL_REPOS=false
# will look for .github/rally.yml in the config repository. If
# a file doesn't exist, it will search for a repo-specific configuration
# If not set, this will look for a default repo at
# [ORG_NAME}/rally-github-config
# [ORG_NAME}/.github
# Example ORG_CONFIG_REPO_NAME=my-custom-config-repo
ORG_CONFIG_REPO_NAME=rally-validator-config
ORG_CONFIG_REPO_NAME=.github
51 changes: 33 additions & 18 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,46 @@ checkPRTitle: true
# Check all commit messages for a Rally story/defect (true | false)
checkCommitMessages: true

# Which projects this repo will link to
rallyProjects: ['Sample Project', 'devops-engineering']

# List of valid Rally artifacts to check
# Valid values:
# defect
# defectsuite
# task
# testcase
# hierarchicalrequirement
# userstory
# story
rallyObjects: ['defect', 'userstory']

# List of Rally statuses that an issue must be in in order to pass
artifactStatuses: ['Defined', 'In-Progress']
# Set Rally Flow State to Complete on merge if the PR Body contains "/completes <DEFECT/STORY ID>"
mergeOnPRBody: true

# Comment on the PR in addition to the check message? (true | false)
commentOnPull: false

rally:
# Optionally override the global Rally URL
server: https://rally1.rallydev.com

## Leave these blank if you use an API key
##username: rallyUser
##password: rallyPass
## This is required if we don't use username/password
## NOTE: If you set this in your .env file then you can
## leave this commented out. It will override your .env
#api_key: _1234abc567...

# Which workspace OID this repo will link to
workspace: 12345

# Which projects this repo will link to.
# To have it connect to any project, leave this value blank
projects:
- Sample Project
- devops-engineering

# List of valid Rally objects to check
objects:
- defect
#- defectsuite
#- task
#- testcase
#- hierarchicalrequirement
- userstory
#- story

# List of Rally states that an issue must be in in order to pass
states:
- Defined
- In-Progress
```

### Creating the GitHub App on your GitHub instance
Expand Down Expand Up @@ -123,6 +137,7 @@ nohup npm start 2>&1 >> /path/to/output.log &
### Environment Variables

- `APP_ID` - The App ID of the **GitHub App**
- `BOT_NAME` - The name of the bot
- `WEBHOOK_SECRET` - The secret to prevent man in the middle attacks
- `GHE_HOST` - This is a required field for **GitHub Enterprise Server** implementations (_Example: github.mycompany.com_)
- `RALLY_SERVER` - URL to connect to **Rally**
Expand All @@ -131,7 +146,7 @@ nohup npm start 2>&1 >> /path/to/output.log &
- `RALLY_API_KEY` - API key to authenticate to **Rally** instead of `RALLY_USERNAME` and `RALLY_PASSWORD`
![rally-token](https://user-images.githubusercontent.com/2894107/89300774-56b89b00-d62e-11ea-94c9-066e12ac5246.png)
- `ENFORCE_ALL_REPOS` - **true** or **false**, will set enforcement of `Rally + GitHub` on all repositories in the installed Organization
- `ORG_CONFIG_REPO_NAME` - Repository name where an organization-level configuration can set default behavior for all repositories (Default: `rally-github-config`)
- `ORG_CONFIG_REPO_NAME` - Repository name where an organization-level configuration can set default behavior for all repositories (Default: `.github`)

One of the following is **required**:
- `PRIVATE_KEY` - The contents of the private key for your **GitHub App**. If you're unable to use multi-line environment variables, use base64 encoding to convert the key to a single line string.
Expand Down
46 changes: 38 additions & 8 deletions lib/RallyValidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RallyValidate {
*/
async getDefaultConfig (context) {
const noFile = true
const orgConfigRepoName = process.env.ORG_CONFIG_REPO_NAME ? process.env.ORG_CONFIG_REPO_NAME : 'rally-github-config'
const orgConfigRepoName = process.env.ORG_CONFIG_REPO_NAME ? process.env.ORG_CONFIG_REPO_NAME : '.github'
let orgConfig

// Get config default from org-level repo .github/rally/<REPO_NAME>.yml
Expand All @@ -94,8 +94,7 @@ class RallyValidate {
path: '.github/rally/' + context.payload.pull_request.base.repo.name + '.yml',
ref: 'master'
})
.catch(() => ({
// Failed to find or open any default config file
.catch(() => ({ // Failed to find or open any default config file
noFile
}))

Expand All @@ -108,8 +107,7 @@ class RallyValidate {
path: '.github/' + configFile,
ref: 'master'
})
.catch(() => ({
// Failed to find or open any default config file
.catch(() => ({ // Failed to find or open any default config file
noFile
}))
}
Expand Down Expand Up @@ -642,11 +640,43 @@ class RallyValidate {
# Check all commit messages for a Rally artifact
checkCommitMessages: true

# List of Rally statuses that an artifact must be in in order to pass
artifactStatuses: ['Open', 'To Do', 'In Progress']

# Comment on the PR in addition to the check message?
commentOnPull: false"

rally:
server: https://rally1.rallydev.com

## Leave these blank if you use an API key
##username: rallyUser
##password: rallyPass
## This is required if we don't use username/password
## NOTE: If you set this in your .env file then you can
## leave this commented out. It will override your .env
#api_key: _1234abc567...

# Which workspace OID this repo will link to
workspace: 12345

# Which projects this repo will link to.
# To have it connect to any project, leave this value blank
projects:
- Sample Project
- devops-engineering

# List of valid Rally objects to check
objects:
- defect
#- defectsuite
#- task
#- testcase
#- hierarchicalrequirement
- userstory
#- story

# List of Rally states that an issue must be in in order to pass
states:
- Defined
- In-Progress
`
return noConfigMessage
}
Expand Down