-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,176 additions
and
1 deletion.
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,64 @@ | ||
# Run a CodeQL analysis on a repository | ||
name: "CodeQL" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
charm-path: | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
# required for all workflows | ||
security-events: write | ||
|
||
# only required for workflows in private repositories | ||
actions: read | ||
contents: read | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# Override automatic language detection by changing the below list | ||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] | ||
language: ['python'] | ||
# Learn more... | ||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
# queries: ./path/to/local/query, your-org/your-repo/queries@main | ||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 https://git.io/JvXDl | ||
|
||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
# and modify them (or add more) to build your code if your project | ||
# uses a compiled language | ||
|
||
#- run: | | ||
# make bootstrap | ||
# make release | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
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,26 @@ | ||
name: Linting | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
charm-path: | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: python3 -m pip install tox | ||
- name: Run linters | ||
run: cd ${{ inputs.charm-path }} && tox -vve lint |
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,102 @@ | ||
name: Quality Checks | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
charm-path: | ||
type: string | ||
required: false | ||
provider: | ||
type: string | ||
description: "The provider to choose for either machine or k8s tests ('lxd' or 'microk8s')" | ||
required: true | ||
ip-range-start: | ||
type: string | ||
description: "The first IP address in the address pool for the load balancer to use" | ||
required: false | ||
default: "{{ env.IPADDR }}" | ||
ip-range-end: | ||
type: string | ||
description: "The last IP address in the address pool for the load balancer to use" | ||
required: false | ||
default: "{{ env.IPADDR }}" | ||
secrets: | ||
CHARMHUB_TOKEN: | ||
required: false | ||
jobs: | ||
check-secret: | ||
name: Check the CHARMHUB_TOKEN secret | ||
runs-on: ubuntu-latest | ||
outputs: | ||
defined: ${{ steps.check.outputs.defined }} | ||
steps: | ||
- id: check | ||
env: | ||
CHARMHUB_TOKEN: ${{ secrets.CHARMHUB_TOKEN }} | ||
if: "${{ env.CHARMHUB_TOKEN != '' }}" | ||
run: echo "defined=true" >> $GITHUB_OUTPUT | ||
call-inclusive-naming-check: | ||
# Issues with this workflow can be addressed by adding a .wokeignore in the repository root | ||
name: Inclusive naming | ||
uses: canonical-web-and-design/Inclusive-naming/.github/workflows/woke.yaml@main | ||
with: | ||
fail-on-error: "true" | ||
lib-check: | ||
name: Check libraries | ||
runs-on: ubuntu-latest | ||
needs: | ||
- check-secret | ||
if: needs.check-secret.outputs.defined == 'true' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Check charm libraries # Make sure our charm libraries are updated | ||
uses: canonical/charming-actions/[email protected] | ||
with: | ||
credentials: "${{ secrets.CHARMHUB_TOKEN }}" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
charm-path: "${{ inputs.charm-path }}" | ||
static-analysis: | ||
name: Static Analysis | ||
uses: canonical/observability/.github/workflows/_charm-static-analysis.yaml@main | ||
with: | ||
charm-path: "${{ inputs.charm-path }}" | ||
linting: | ||
name: Linting | ||
uses: canonical/observability/.github/workflows/_charm-linting.yaml@main | ||
with: | ||
charm-path: "${{ inputs.charm-path }}" | ||
unit-test: | ||
name: Unit Tests | ||
uses: canonical/observability/.github/workflows/_charm-tests-unit.yaml@main | ||
with: | ||
charm-path: "${{ inputs.charm-path }}" | ||
scenario-test: | ||
name: Scenario Tests | ||
uses: canonical/observability/.github/workflows/_charm-tests-scenario.yaml@main | ||
with: | ||
charm-path: "${{ inputs.charm-path }}" | ||
integration-test: | ||
name: Integration Tests | ||
needs: | ||
- static-analysis | ||
- linting | ||
- unit-test | ||
- scenario-test | ||
uses: canonical/observability/.github/workflows/_charm-tests-integration.yaml@main | ||
with: | ||
charm-path: "${{ inputs.charm-path }}" | ||
provider: "${{ inputs.provider }}" | ||
ip-range-start: ${{ inputs.ip-range-start }} | ||
ip-range-end: ${{ inputs.ip-range-end }} | ||
codeql: | ||
name: CodeQL analysis | ||
needs: | ||
- static-analysis | ||
- linting | ||
- unit-test | ||
uses: canonical/observability/.github/workflows/_charm-codeql-analysis.yml@main | ||
with: | ||
charm-path: "${{ inputs.charm-path }}" |
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,97 @@ | ||
name: Release charm to Edge | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
charm-path: | ||
type: string | ||
required: false | ||
default: . | ||
artifact: | ||
description: "Name of artifact to download before building. Must contain the file artifact.tar.gz." | ||
default: '' | ||
required: false | ||
type: string | ||
secrets: | ||
CHARMHUB_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
build: | ||
name: Build the charms | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
charms: ${{ steps.builder.outputs.charms }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Setup LXD | ||
uses: canonical/[email protected] | ||
with: | ||
channel: latest/stable | ||
- name: Download Artifact | ||
uses: actions/download-artifact@v3 | ||
id: download_artifact | ||
with: | ||
name: "${{ inputs.artifact }}" | ||
if: ${{ inputs.artifact != '' }} | ||
- name: Unpack Artifact | ||
run: sudo apt-get update && sudo apt-get install tar && tar xf artifact.tar.gz | ||
if: ${{ inputs.artifact != '' }} | ||
- name: Build charm(s) | ||
id: builder | ||
run: | | ||
sudo snap install jq | ||
sudo snap install charmcraft --classic | ||
charmcraft pack --project-dir ${{ inputs.charm-path }} | ||
export CHARMS=$(ls ${{ inputs.charm-path }}/*.charm | jq -R -s -c 'split("\n")[:-1]') | ||
echo "charms=$CHARMS" >> "$GITHUB_OUTPUT" | ||
- name: Store charms | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: charms | ||
path: ${{ inputs.charm-path }}/*.charm | ||
- name: Step output | ||
run: | | ||
echo "${{ fromjson(steps.builder.outputs.charms) }} " | ||
charm-output: | ||
name: Charm List | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- build | ||
steps: | ||
- name: Job output | ||
run: | | ||
echo job output: ${{ fromjson(needs.build.outputs.charms) }} | ||
release-to-charmhub: | ||
name: Release to CharmHub | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- build | ||
strategy: | ||
matrix: | ||
path: ${{ fromjson(needs.build.outputs.charms) }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Select charmhub channel | ||
uses: canonical/charming-actions/[email protected] | ||
id: channel | ||
- name: Fetch charm artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: charms | ||
- name: Upload charm to charmhub | ||
uses: canonical/charming-actions/[email protected] | ||
with: | ||
credentials: "${{ secrets.CHARMHUB_TOKEN }}" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
channel: "${{ steps.channel.outputs.name }}" | ||
built-charm-path: "${{ matrix.path }}" | ||
# We set destructive mode to false, otherwise runner's OS would have to match | ||
# charm's 'build-on' OS. | ||
destructive-mode: false |
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,42 @@ | ||
name: Static Analysis | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
charm-path: | ||
type: string | ||
required: false | ||
|
||
jobs: | ||
static-lib: | ||
name: Static Analysis of Libs | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: python3 -m pip install tox | ||
- name: Run static analysis for /lib for 3.8 | ||
run: cd ${{ inputs.charm-path }} && tox -vve static-lib | ||
static-charm: | ||
name: Static Analysis of Charm | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Install dependencies | ||
run: python3 -m pip install tox | ||
- name: Run static analysis (charm) | ||
run: cd ${{ inputs.charm-path }} && tox -vve static-charm |
Oops, something went wrong.