Skip to content

Commit

Permalink
Remove old files and use new templates [SOLENG-833] (#90)
Browse files Browse the repository at this point in the history
* Remove old files and use new templates

Note that check.yaml differs from the snap_check template in automation,
because currently the snap_check template does not have a job for unit
tests.
  • Loading branch information
samuelallan72 authored Nov 24, 2024
1 parent 3178284 commit 70afa06
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 154 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Tests

on:
workflow_call:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]
paths-ignore:
- "**.md"
- "**.rst"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Complete git history is required to generate the version from git tags.

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
sudo apt update
sudo apt install -y yamllint
python -m pip install --upgrade pip
# pin tox to the current major version to avoid
# workflows breaking all at once when a new major version is released.
python -m pip install 'tox<5'
- name: Run linters
run: tox -e lint

- name: Lint yaml files
run: |
yamllint .yamllint snap/snapcraft.yaml
unit:
name: Unit
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install 'tox<5'
- name: Run unit tests
run: tox -e unit

build:
needs:
- lint
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [[ubuntu-22.04]]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Complete git history is required to generate the version from git tags.

- name: Verify snap builds successfully
id: build
uses: canonical/action-build@v1

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

- name: Upload the built snap
uses: actions/upload-artifact@v4
with:
name: snap_${{ env.SYSTEM_ARCH }}
path: ${{ steps.build.outputs.snap }}

func:
needs:
- build
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [[ubuntu-22.04]]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Complete git history is required to generate the version from git tags.

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

- name: Download snap file artifact
uses: actions/download-artifact@v4
with:
name: snap_${{ env.SYSTEM_ARCH }}

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install 'tox<5'
- name: Setup Juju environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: "lxd"
juju-channel: "3.5/stable"
charmcraft-channel: "3.x/stable"

- name: Run func tests
run: |
export TEST_SNAP="$(pwd)/$(ls | grep '.*_.*\.snap$')"
echo "$TEST_SNAP"
tox -e func
30 changes: 0 additions & 30 deletions .github/workflows/pr.yaml

This file was deleted.

32 changes: 23 additions & 9 deletions .github/workflows/promote.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
name: Promote snap to other tracks and channels
# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation
# To update the file:
# - Edit it in the canonical/solutions-engineering-automation repository.
# - Open a PR with the changes.
# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes.
name: Promote snap to default track, standard risk levels.

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel, e.g. latest/candidate'
required: true
origin-channel:
description: 'Origin Channel, e.g. latest/edge'
channel-promotion:
description: 'Channel Promotion, e.g. latest/edge -> latest/candidate'
required: true
type: choice
options:
- 'latest/edge -> latest/candidate'
- 'latest/candidate -> latest/stable'

jobs:
promote-snap:
name: Promote snap
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Snapcraft install
run: sudo snap install --classic snapcraft
- name: Get snap name
id: snap
run: echo "name=$(awk '/^name:/ {print $2}' snap/snapcraft.yaml)" >> "$GITHUB_OUTPUT"
- name: Set channels
id: set-channels
run: |
channel_promotion="${{ github.event.inputs.channel-promotion }}"
origin=$(echo "$channel_promotion" | sed 's/\s*->.*//')
destination=$(echo "$channel_promotion" | sed 's/.*->\s*//')
echo "destination-channel=$destination" >> $GITHUB_OUTPUT
echo "origin-channel=$origin" >> $GITHUB_OUTPUT
- name: Snapcraft promote snap
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
Expand All @@ -30,5 +44,5 @@ jobs:
# refuse to non-interactively promote a snap from the edge
# channel if it is done without any branch qualifiers
yes | snapcraft promote ${{ steps.snap.outputs.name }} \
--from-channel ${{ github.event.inputs.origin-channel }} \
--to-channel ${{ github.event.inputs.destination-channel }}
--from-channel ${{ steps.set-channels.outputs.origin-channel }} \
--to-channel ${{ steps.set-channels.outputs.destination-channel }}
35 changes: 24 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# This file is centrally managed as a template file in https://github.com/canonical/solutions-engineering-automation
# To update the file:
# - Edit it in the canonical/solutions-engineering-automation repository.
# - Open a PR with the changes.
# - When the PR merges, the soleng-terraform bot will open a PR to the target repositories with the changes.
name: Publish snap

on:
Expand All @@ -8,27 +13,35 @@ on:

jobs:
check:
uses: ./.github/workflows/pr.yaml
uses: ./.github/workflows/check.yaml
secrets: inherit

release:
runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}
needs: check
outputs:
snap: ${{ steps.build.outputs.snap }}
strategy:
fail-fast: false
matrix:
runs-on: [[ubuntu-22.04]]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for version determination
- uses: snapcore/action-build@v1
id: build
- uses: actions/upload-artifact@v4
fetch-depth: 0 # Complete git history is required to generate the version from git tags.

- name: Determine system architecture
run: echo "SYSTEM_ARCH=$(uname -m)" >> $GITHUB_ENV

- name: Download the built snap from check workflow
uses: actions/download-artifact@v4
with:
name: snap
path: ${{ steps.build.outputs.snap }}
name: snap_${{ env.SYSTEM_ARCH }}

- name: Find the downloaded snap file
run: echo "SNAP_FILE=$(find . -name "*.snap")" >> $GITHUB_ENV

- uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ steps.build.outputs.snap }}
snap: ${{ env.SNAP_FILE }}
release: latest/edge,3/edge
22 changes: 0 additions & 22 deletions .pre-commit-config.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends: default

rules:
line-length: disable
document-start: disable
64 changes: 0 additions & 64 deletions Makefile

This file was deleted.

17 changes: 0 additions & 17 deletions rename.sh

This file was deleted.

Loading

0 comments on commit 70afa06

Please sign in to comment.