Skip to content

Commit

Permalink
feat(travis): push notifications to saltstack-formulas.zulipchat.com
Browse files Browse the repository at this point in the history
* Use `%2F` for the forward slash in the topic name:
  - https://docs.travis-ci.com/user/triggering-builds/
  - https://www.degraeve.com/reference/urlencoding.php
* Use Travis `if` conditional rather than `secret` encrypted enviroment
  variable workaround suggested:
  - Not a secret, just the bot's API key
  - Need to be able to modify parts of the URL in certain situations,
    such as the weekly `master` branch tests
  - References:
    + https://docs.travis-ci.com/user/environment-variables/#encrypting-environment-variables
    + travis-ci/travis-ci#329
    + travis-ci/travis-ci#1094
    + travis-ci/travis-ci#5063
    + travis-ci/travis-ci#6100
    + mozilla/build-tools@c13a297
  • Loading branch information
myii committed May 21, 2020
1 parent 10ef1ca commit a1e50da
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,15 @@ jobs:
edge: true
# Run `semantic-release`
script: 'npx semantic-release@15.14'

# Notification options: `always`, `never` or `change`
notifications:
webhooks:
if: 'repo = myii/ssf-formula'
urls:
- https://saltstack-formulas.zulipchat.com/api/v1/external/travis?api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P&stream=CI&topic=myii%2Fssf-formula&ignore_pull_requests=false
on_success: always # default: always
on_failure: always # default: always
on_start: always # default: never
on_cancel: always # default: always
on_error: always # default: always
4 changes: 3 additions & 1 deletion ssf/config/formulas.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{%- set use_cirrus_ci = context.use_cirrus_ci %}
{%- set use_libsaltcli = context.use_libsaltcli %}
{%- set use_tofs = context.use_tofs %}
{%- set owner = context.git.github.owner %}
{%- set formula = context.git.github.repo %}
{#- Determine the TOFS override directory for the current formula #}
{#- Can't use `formula` directly because some formula names are used as top-level pillar/config keys, such as `users-formula` #}
Expand Down Expand Up @@ -125,6 +126,7 @@ prepare-git-branch-for-{{ formula }}:
{#- Maintaining the rest for consistency #}
tplroot: {{ tplroot }}
semrel_formula: {{ semrel_file_specs.alt_semrel_formula | d(semrel_formula) }}
owner: {{ owner }}
formula: {{ formula }}
codeowners: {{ context.codeowners | yaml }}
inspec_suites_kitchen: {{ inspec_suites_kitchen | yaml }}
Expand Down Expand Up @@ -208,7 +210,7 @@ create-github-PR-for-{{ formula }}:
- cwd: {{ ssf.formulas_path }}/{{ formula }}/
- args: >-
create-github-PR-for-{{ formula }}
{{ context.git.github.owner }}
{{ owner }}
{{ formula }}
{{ context.git.branch.base }}
{{ ssf.git.github.user }}
Expand Down
4 changes: 2 additions & 2 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ ssf_node_anchors:
# An alternative method could be to use:
# `git describe --abbrev=0 --tags`
# yamllint disable rule:line-length rule:quoted-strings
title: "ci(kitchen+travis): adjust matrix to add '`'3000.3'`'"
body: '* Semi-automated using /~https://github.com/myii/ssf-formula/pull/190'
title: "ci(travis): add notifications ='>' zulip [skip ci]"
body: '* Automated using /~https://github.com/myii/ssf-formula/pull/191'
# yamllint enable rule:line-length rule:quoted-strings
github:
owner: 'saltstack-formulas'
Expand Down
26 changes: 26 additions & 0 deletions ssf/files/default/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,29 @@ jobs:
edge: true
# Run `semantic-release`
script: 'npx semantic-release@15.14'
{%- if semrel_formula == 'template' %}
# <REMOVEME
{%- endif %}

# Notification options: `always`, `never` or `change`
{#- TODO: Move this to `defaults.yaml` & `formulas.yaml` #}
{%- set ignore_pull_requests = 'false' if semrel_formula in ['ssf'] else 'true' %}
notifications:
webhooks:
if: 'repo = {{ owner }}/{{ formula }}'
urls:
- {{ 'https://{}/api/v1/external/travis?{}&{}&{}&{}'.format(
'saltstack-formulas.zulipchat.com',
'api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P',
'stream=CI',
'topic={}%2F{}'.format(owner, formula),
'ignore_pull_requests={}'.format(ignore_pull_requests),
) }}
on_success: always # default: always
on_failure: always # default: always
on_start: always # default: never
on_cancel: always # default: always
on_error: always # default: always
{%- if semrel_formula == 'template' %}
# REMOVEME>
{%- endif %}
20 changes: 20 additions & 0 deletions ssf/files/tofs_arvados-formula/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,23 @@ jobs:
edge: true
# Run `semantic-release`
script: 'npx semantic-release@15.14'

# Notification options: `always`, `never` or `change`
{#- TODO: Move this to `defaults.yaml` & `formulas.yaml` #}
{%- set ignore_pull_requests = 'false' if semrel_formula in ['ssf'] else 'true' %}
notifications:
webhooks:
if: 'repo = {{ owner }}/{{ formula }}'
urls:
- {{ 'https://{}/api/v1/external/travis?{}&{}&{}&{}'.format(
'saltstack-formulas.zulipchat.com',
'api_key=HsIq3o5QmLxdnVCKF9is0FUIpkpAY79P',
'stream=CI',
'topic={}%2F{}'.format(owner, formula),
'ignore_pull_requests={}'.format(ignore_pull_requests),
) }}
on_success: always # default: always
on_failure: always # default: always
on_start: always # default: never
on_cancel: always # default: always
on_error: always # default: always

0 comments on commit a1e50da

Please sign in to comment.