|
| 1 | +name: Build and test charm |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +env: |
| 12 | + DEBIAN_FRONTEND: noninteractive |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + name: Lint |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 23 | + with: |
| 24 | + persist-credentials: false |
| 25 | + - name: Install dependencies |
| 26 | + run: sudo snap install ruff --classic |
| 27 | + - name: Run linters |
| 28 | + run: ruff check --preview . |
| 29 | + working-directory: charm |
| 30 | + |
| 31 | + lib-check: |
| 32 | + name: Check libraries |
| 33 | + runs-on: ubuntu-24.04 |
| 34 | + permissions: |
| 35 | + contents: write |
| 36 | + pull-requests: write |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 40 | + with: |
| 41 | + # fetch-depth: 0 # TODO optimize that for speed |
| 42 | + persist-credentials: false |
| 43 | + - name: Check libs |
| 44 | + uses: canonical/charming-actions/check-libraries@1753e0803f70445132e92acd45c905aba6473225 # 2.7.0 |
| 45 | + with: |
| 46 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 47 | + charm-path: . |
| 48 | + |
| 49 | + pack-charm: |
| 50 | + name: Build charm |
| 51 | + runs-on: ubuntu-24.04 |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 55 | + with: |
| 56 | + persist-credentials: false |
| 57 | + |
| 58 | + - name: Setup LXD |
| 59 | + uses: canonical/setup-lxd@a3c85fc6fb7fff43fcfeae87659e41a8f635b7dd |
| 60 | + |
| 61 | + - name: Install ~~charmcraft~~spread |
| 62 | + run: sudo snap install charmcraft --classic |
| 63 | + |
| 64 | + - name: Pack charm |
| 65 | + run: charmcraft pack -v |
| 66 | + |
| 67 | + - name: Run charm tests |
| 68 | + run: | |
| 69 | + charmcraft.spread -v charm/tests/ |
| 70 | +
|
| 71 | + - name: Upload charm artifact |
| 72 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 73 | + with: |
| 74 | + name: error-tracker.charm |
| 75 | + path: "*.charm" |
| 76 | + |
| 77 | + - name: Upload charm to charmhub |
| 78 | + uses: canonical/charming-actions/upload-charm@1753e0803f70445132e92acd45c905aba6473225 # 2.7.0 |
| 79 | + with: |
| 80 | + credentials: '${{ secrets.CHARMHUB_TOKEN }}' |
| 81 | + github-token: '${{ secrets.GITHUB_TOKEN }}' |
| 82 | + tag-prefix: ${{ matrix.charm }} |
| 83 | + built-charm-path: [email protected] |
| 84 | + if: github.ref == 'refs/heads/main' |
0 commit comments