Fix upload crash when run outside project directory #7246
This file contains hidden or 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
| name: Spread | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - .github/** | |
| - "!.github/workflows/spread.yaml" # Run on this file getting changed | |
| - docs/** | |
| - schema/** | |
| - tests/** # Don't run if only tests changed, unless a spread test changed. | |
| - "!tests/spread/**" | |
| - .editorconfig | |
| - .pre-commit-config.yaml | |
| - .readthedocs.yaml | |
| - "*.md" # Only top-level Markdown files | |
| merge_group: | |
| paths-ignore: | |
| - .github/** | |
| - "!.github/workflows/spread.yaml" # Run on this file getting changed | |
| - docs/** | |
| - schema/** | |
| - tests/** # Don't run if only tests changed, unless a spread test changed. | |
| - "!tests/spread/**" | |
| - .editorconfig | |
| - .pre-commit-config.yaml | |
| - .readthedocs.yaml | |
| - "*.md" # Only top-level Markdown files | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - .github/** | |
| - "!.github/workflows/spread.yaml" # Run on this file getting changed | |
| - docs/** | |
| - schema/** | |
| - tests/** # Don't run if only tests changed, unless a spread test changed. | |
| - "!tests/spread/**" | |
| - .editorconfig | |
| - .pre-commit-config.yaml | |
| - .readthedocs.yaml | |
| - "*.md" # Only top-level Markdown files | |
| schedule: | |
| - cron: "0 0 */2 * *" | |
| jobs: | |
| snap-build: | |
| runs-on: [self-hosted, amd64] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Build snap | |
| uses: snapcore/action-build@v1 | |
| id: charmcraft | |
| - name: Upload snap artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: snap | |
| path: ${{ steps.charmcraft.outputs.snap }} | |
| spread-select: | |
| runs-on: spread-installed | |
| outputs: | |
| systems: ${{ steps.select.outputs.systems }} | |
| steps: | |
| - name: Checkout charmcraft | |
| uses: actions/checkout@v5 | |
| - name: Find spread systems | |
| id: select | |
| run: | | |
| echo systems=$(spread -list google: | cut -d: -f2 | sort | uniq | jq --raw-input . | jq --slurp --compact-output) | tee -a "${GITHUB_OUTPUT}" | |
| snap-tests: | |
| runs-on: spread-installed | |
| needs: [snap-build, spread-select] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| system: ${{ fromJSON(needs.spread-select.outputs.systems) }} | |
| steps: | |
| - name: Cleanup job workspace | |
| run: | | |
| rm -rf "${{ github.workspace }}" | |
| mkdir "${{ github.workspace }}" | |
| - name: Checkout charmcraft | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Download snap artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: snap | |
| - name: Run spread | |
| run: | | |
| spread google:${{ matrix.system }} | |
| - name: Discard spread workers | |
| if: always() | |
| run: | | |
| shopt -s nullglob | |
| for r in .spread-reuse.*.yaml; do | |
| spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')" | |
| done | |
| snap-store-tests: | |
| runs-on: spread-installed | |
| needs: [snap-build] | |
| steps: | |
| - if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'canonical') || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
| name: Checkout charmcraft | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'canonical') || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
| name: Download snap artifact | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: snap | |
| - if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login == 'canonical') || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
| name: Run spread | |
| env: | |
| CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_AUTH }} | |
| CHARMCRAFT_SINGLE_CHARM_AUTH: ${{ secrets.CHARMCRAFT_SINGLE_CHARM_AUTH }} | |
| CHARM_DEFAULT_NAME: gh-ci-charmcraft-charm | |
| run: | | |
| spread google:ubuntu-22.04-64:tests/spread/store/ |