Skip to content

Commit

Permalink
Test ci (#2)
Browse files Browse the repository at this point in the history
* Add Prometheus monitoring with Grafana dashboard (canonical#48)

* Add prometheus monitoring relation
* temporarily disable test that uses deprecated feature of ops library

Co-authored-by: Natasha Ho <[email protected]>

* Add charming actions (canonical#59)

* add charming actions

* update libs

* Add condition to only run publish action if repo owner is canonical

* Add condition to existing if

* Add condition to check-libs

* Move lib-check to merged condition

* Fix typo in condition

* Remove duplicate check-lib

* Add lib-check as prereq for publish-charm

* Remove publish-charm conditions from incorrect merge conflict

* test

Co-authored-by: Natasha Ho <[email protected]>
Co-authored-by: natalian98 <[email protected]>
  • Loading branch information
3 people authored Jun 15, 2022
1 parent ff66ebc commit dff9f75
Show file tree
Hide file tree
Showing 17 changed files with 6,736 additions and 26 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# reusable workflow triggered by other actions
name: CI

on:
push:
branches:
- master
pull_request:
workflow_call:
secrets:
charmcraft-credentials:
required: true

jobs:


lint:
name: Lint Code
runs-on: ubuntu-latest
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test and publish to branch

# On pull_request, we:
# * always publish to charmhub at latest/edge/branchname
# * always run tests

on:
pull_request:

jobs:

tests:
name: Run Tests
uses: ./.github/workflows/integrate.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"

# publish runs in parallel with tests, as we always publish in this situation
publish-charm:
name: Publish Charm
uses: ./.github/workflows/publish.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"
31 changes: 31 additions & 0 deletions .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to edge if tests passed

# On push to a "special" branch, we:
# * always publish to charmhub at latest/edge/branchname
# * always run tests
# where a "special" branch is one of main/master or track/**, as
# by convention these branches are the source for a corresponding
# charmhub edge channel.

on:
push:
branches:
- master
- main
- track/**

jobs:

tests:
name: Run Tests
uses: ./.github/workflows/integrate.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"

# publish runs in series with tests, and only publishes if tests passes
publish-charm:
name: Publish Charm
needs: tests
uses: ./.github/workflows/publish.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"
52 changes: 35 additions & 17 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
# reusable workflow triggered by other actions
name: Publish

on:
push:
branches:
- master
- main
- track/**
pull_request:
branches:
- master
- main
- track/**
workflow_call:
secrets:
charmcraft-credentials:
required: true

jobs:

lib-check:
name: Check libraries
runs-on: ubuntu-latest
if: (github.event.pull_request.merged == true)
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check libs
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.charmcraft-credentials }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"

publish-charm:
name: Publish Charm
runs-on: ubuntu-latest
# Only publish to charmhub if we are pushing to a special branch or running PRs from something named `branch/*`
if: (github.event_name == 'push') || (startsWith( github.head_ref, 'branch/' ))
if: (github.event.pull_request.merged == true)
needs: lib-check
steps:
- uses: actions/checkout@v2
- uses: canonical/[email protected]
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Select charmhub channel
uses: canonical/charming-actions/[email protected]
id: channel
- name: Upload charm to charmhub
uses: canonical/charming-actions/[email protected]
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
charm-path: ./
charmcraft-channel: latest/edge
credentials: "${{ secrets.charmcraft-credentials }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
channel: "${{ steps.channel.outputs.name }}"
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# reusable workflow triggered manually
name: Release charm to other tracks and channels

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel'
required: true
origin-channel:
description: 'Origin Channel'
required: true

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Release charm to channel
uses: canonical/charming-actions/[email protected]
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
destination-channel: ${{ github.event.inputs.destination-channel }}
origin-channel: ${{ github.event.inputs.origin-channel }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.charm
build/
__pycache__/
.tox
Loading

0 comments on commit dff9f75

Please sign in to comment.