-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add snapcraft recipe * add snap ci workflows * Update CHANGELOG.md * Update snapcraft.yaml * remove setup.py * should stay as unreleased until the actual package is bumped * no need to bump as cos-alerter did not change * put back setup.py * use packages instead of package-dir * ignore snaps * comment explaining setup.py --------- Co-authored-by: Dylan Stephano-Shachter <dylan.stephano-shachter@canonical.com>
- Loading branch information
Showing
7 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Promote Snap | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
promotion: | ||
type: choice | ||
description: Channel to promote from | ||
options: | ||
- edge -> beta | ||
- beta -> candidate | ||
- candidate -> stable | ||
|
||
env: | ||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | ||
|
||
jobs: | ||
promote: | ||
name: Promote Snap | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install dependencies | ||
run: sudo snap install --classic --channel edge snapcraft | ||
- name: Set target channel | ||
env: | ||
PROMOTE_FROM: ${{ github.event.inputs.promotion }} | ||
run: | | ||
if [ "${PROMOTE_FROM}" == "edge -> beta" ]; then | ||
echo "promote-from=edge" >> ${GITHUB_ENV} | ||
echo "promote-to=beta" >> ${GITHUB_ENV} | ||
elif [ "${PROMOTE_FROM}" == "beta -> candidate" ]; then | ||
echo "promote-from=beta" >> ${GITHUB_ENV} | ||
echo "promote-to=candidate" >> ${GITHUB_ENV} | ||
elif [ "${PROMOTE_FROM}" == "candidate -> stable" ]; then | ||
echo "promote-from=candidate" >> ${GITHUB_ENV} | ||
echo "promote-to=stable" >> ${GITHUB_ENV} | ||
fi | ||
- name: Fetch Revision | ||
run: | | ||
SNAP_RELEASES=$(curl -s -H "Snap-Device-Series: 16" "http://api.snapcraft.io/v2/snaps/info/cos-alerter?fields=revision") | ||
REVISION=$(echo $SNAP_RELEASES | jq '."channel-map"[] | select(.channel.risk=="${{ env.promote-from }}").revision') | ||
echo "revision=$REVISION" >> ${GITHUB_ENV} | ||
- name: Promote Snap | ||
run: | | ||
snapcraft release cos-alerter ${{ env.revision }} ${{ env.promote-to }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Release Snap | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- snap/** | ||
|
||
|
||
env: | ||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup LXD | ||
uses: canonical/setup-lxd@v0.1.1 | ||
with: | ||
channel: latest/stable | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo snap install --classic --channel edge snapcraft | ||
- name: Build Snap | ||
run: snapcraft pack --output cos-alerter.snap | ||
|
||
- name: Upload and Publish Snap | ||
run: snapcraft upload --release edge cos-alerter.snap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ cos-alerter.yaml | |
dist | ||
venv | ||
*.egg-info | ||
*.snap | ||
**/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# This file is needed for some reason to make snapcraft work. | ||
# https://github.com/snapcore/snapcraft/issues/4300 | ||
|
||
from setuptools import setup | ||
|
||
setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: cos-alerter | ||
version: '0.4.0' | ||
summary: A watchdog alerting on alertmanager notification failures. | ||
license: Apache-2.0 | ||
contact: simon.aronsson@canonical.com | ||
issues: https://github.com/canonical/cos-alerter/issues | ||
source-code: https://github.com/canonical/cos-alerter/ | ||
website: https://charmhub.io/topics/canonical-observability-stack/ | ||
description: | | ||
COS Alerter is a watchdog used to alert on alertmanager notification failures. | ||
By leveraging an always-firing alert rule routed specifically to cos-alerter, you'll | ||
be alerted if the pings stop happening - meaning your alertmanager is likely malfunctioning. | ||
base: core22 | ||
grade: stable | ||
confinement: strict | ||
compression: lzo | ||
|
||
plugs: | ||
etc-cos-alerter: | ||
interface: system-files | ||
read: | ||
- /etc/cos-alerter.yaml | ||
|
||
parts: | ||
cos-alerter: | ||
plugin: python | ||
source: . | ||
|
||
apps: | ||
daemon: | ||
command: bin/cos-alerter --config /etc/cos-alerter.yaml | ||
install-mode: disable | ||
restart-condition: on-failure | ||
daemon: simple | ||
plugs: | ||
- network | ||
- network-bind | ||
- etc-cos-alerter |