Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/build-and-test-charm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Build and test charm

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
DEBIAN_FRONTEND: noninteractive

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false
- name: Install dependencies
run: sudo snap install ruff --classic
- name: Run linters
run: ruff check --preview .
working-directory: charm

lib-check:
name: Check libraries
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
# fetch-depth: 0 # TODO optimize that for speed
persist-credentials: false
- name: Check libs
uses: canonical/charming-actions/check-libraries@1753e0803f70445132e92acd45c905aba6473225 # 2.7.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
charm-path: .

pack-charm:
name: Build charm
runs-on: ubuntu-latest
steps:
- name: Aggressive cleanup to regain disk space
run: |
# Remove Java (JDKs)
sudo rm -rf /usr/lib/jvm
# Remove .NET SDKs
sudo rm -rf /usr/share/dotnet
# Remove Swift toolchain
sudo rm -rf /usr/share/swift
# Remove Haskell (GHC)
sudo rm -rf /usr/local/.ghcup
# Remove Julia
sudo rm -rf /usr/local/julia*
# Remove Android SDKs
sudo rm -rf /usr/local/lib/android
# Remove Chromium (optional if not using for browser tests)
sudo rm -rf /usr/local/share/chromium
# Remove Microsoft/Edge and Google Chrome builds
sudo rm -rf /opt/microsoft /opt/google

- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
persist-credentials: false

- name: Setup LXD
uses: canonical/setup-lxd@a3c85fc6fb7fff43fcfeae87659e41a8f635b7dd

- name: Install ~~charmcraft~~spread
run: sudo snap install charmcraft --classic

- name: Pack charm
run: charmcraft pack -v

- name: Run charm tests
run: |
charmcraft.spread -v charm/tests/

- name: Upload charm artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: error-tracker.charm
path: "*.charm"

- name: Upload charm to charmhub
uses: canonical/charming-actions/upload-charm@1753e0803f70445132e92acd45c905aba6473225 # 2.7.0
with:
credentials: '${{ secrets.CHARMHUB_TOKEN }}'
github-token: '${{ secrets.GITHUB_TOKEN }}'
tag-prefix: ${{ matrix.charm }}
built-charm-path: [email protected]
if: github.ref == 'refs/heads/main'
121 changes: 0 additions & 121 deletions .github/workflows/build-and-test-charms.yaml

This file was deleted.

59 changes: 26 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
name: CI

on: # yamllint disable-line rule:truthy
- push
- pull_request
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
DEBIAN_FRONTEND: noninteractive
Expand All @@ -27,36 +31,25 @@ jobs:
# TODO: reenable that after cleaning everything. Those tests are nowhere
# near ready to be run again, and will likely just get replaced once bigger
# refactoring will have occured.
# tests:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# container:
# - ubuntu:latest
# - ubuntu:rolling
# container:
# image: ${{ matrix.container }}
# steps:
# - name: Sanitize container name (for artifact name)
# run: |
# container=$(echo "${{ matrix.container }}" | sed 's/:/-/')
# echo "JOB=${GITHUB_JOB}-${container}" >> "$GITHUB_ENV"
# - name: Install dependencies
# run: >
# apt-get update
# && apt-get install --no-install-recommends --yes
# apport-retrace git python3-amqp python3-cassandra python3-pygit2
# python3-swiftclient ubuntu-dbgsym-keyring
# - name: Run unit and integration tests
# run: >
# python3 -m pytest -ra --cov=$(pwd) --cov-branch --cov-report=xml
# --durations=0 src/test
# - name: Upload coverage
# uses: actions/upload-artifact@v4
# with:
# name: coverage-${{ env.JOB }}
# path: ./coverage*.xml
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Setup LXD
uses: canonical/setup-lxd@a3c85fc6fb7fff43fcfeae87659e41a8f635b7dd
- name: Install ~~charmcraft~~spread
run: sudo snap install charmcraft --classic
- name: Run Error Tracker tests
run: |
charmcraft.spread -v tests/errortracker/
# spread artifacts need to work to re-enable this
# - name: Upload coverage
# uses: actions/upload-artifact@v4
# with:
# name: coverage-${{ env.JOB }}
# path: ./coverage.xml

woke:
name: woke
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Charm
*.charm

# Spread
.spread*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -57,7 +63,7 @@ cover/

# Django stuff:
*.log
local_settings.py
local_config.py
db.sqlite3
db.sqlite3-journal

Expand Down
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
# error-tracker

Code behind https://errors.ubuntu.com

## Dependencies

## Running the tests locally with spread

This avoids having to install all the Python dependencies and runs everything
isolated in a LXD VM, but is a bit slower for development.
This is also how the CI runs the tests, so if it breaks, that's likely to be the
first step to reproduce locally.
```
sudo snap install lxd --classic
sudo snap install charmcraft --classic
charmcraft.spread -v -reuse -resend
```

## Setting up local development


Start with the Python dependencies
```
sudo apt install apport-retrace python3-amqp python3-bson python3-cassandra python3-flask python3-mock python3-pygit2 python3-pytest python3-pytest-cov python3-swiftclient ubuntu-dbgsym-keyring
```

Then start a local Cassandra, RabbitMQ and swift (`docker` should works fine too):
```
podman run --name cassandra --network host --rm -d -e HEAP_NEWSIZE=10M -e MAX_HEAP_SIZE=200M docker.io/cassandra
podman run --name rabbitmq --network host --rm -d docker.io/rabbitmq
podman run --name swift --network host --rm -d docker.io/openstackswift/saio
```

You can then then run the tests with `pytest`:
```
cd src
python3 -m pytest -o log_cli=1 -vv --log-level=INFO tests/
```

Or start each individual process (from the `./src` folder):

daisy:
```
python3 ./daisy/app.py
```

retracer:
```
python3 ./retracer.py -a amd64 --sandbox-dir /tmp/sandbox -v --config-dir ./retracer/config
```

From there, you can manually upload a crash with the following, from any folder
containing a `.crash` file with its corresponding `.upload` file:
```
sudo apt install python3-amqp python3-cassandra apport-retrace ubuntu-dbgsym-keyring
CRASH_DB_URL=http://127.0.0.1:5000 APPORT_REPORT_DIR=$(pwd) CRASH_DB_IDENTIFIER=my_custom_machine_id whoopsie --no-polling -f
```
This will create a corresponding `.uploaded` file containing the OOPS ID, that
you need to delete if you want to upload the crash again.


## Documentation
## More documentation

### Opening a new series

Expand Down
Loading
Loading