Skip to content

docs: fix tutorial by including a status check after stopping http-server #1250

docs: fix tutorial by including a status check after stopping http-server

docs: fix tutorial by including a status check after stopping http-server #1250

Workflow file for this run

name: Pebble snap
on:
pull_request:
branches: [master]
push:
branches: [master]
release:
types: [published]
# We don't want this workflow to have multiple runs in parallel because
# what could happen is that a slow-running and older execution will upload
# an older snap to `edge`, after the newer and latest snap has already been released.
concurrency: ${{ github.workflow }}
env:
SNAP_NAME: pebble
DEFAULT_TRACK: latest
DEFAULT_RISK: edge
jobs:
local-build:
runs-on: ubuntu-latest
# PRS usually come from forks, which are not allowed to access repo secrets.
# So this job builds the snap locally, and not via LP.
if: github.event_name == 'pull_request'
steps:
- name: Checkout Pebble repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
# Generate the version for the local snap build.
- run: go generate ./cmd
- name: Build ${{ env.SNAP_NAME }} Snap
id: build-snap
uses: snapcore/[email protected]
- uses: actions/upload-artifact@v3
if: failure()
with:
name: snapcraft-logs
path: |
~/.cache/snapcraft/log/
~/.local/state/snapcraft/log/
${{ env.SNAP_NAME }}_*.txt
- name: Attach ${{ steps.build-snap.outputs.snap }} to GH workflow execution
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build-snap.outputs.snap }}
path: ${{ steps.build-snap.outputs.snap }}
remote-build:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
strategy:
fail-fast: true
matrix:
arch: ["amd64", "arm64", "ppc64el", "armhf", "s390x"]
steps:
- name: Checkout Pebble repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set LP credentials for remote build
run: |
lp_creds_path="$HOME/.local/share/snapcraft/"
mkdir -p $lp_creds_path
echo '${{ secrets.LP_CREDENTIALS }}' > ${lp_creds_path}/launchpad-credentials
git config --global user.email "${{ secrets.PEBBLE_DEV_MAILING_LIST}}"
git config --global user.name "pebble-dev"
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
# Ensure Snapcraft will ship the generated version files to LP.
- run: |
go generate ./cmd
git add -f ./cmd/VERSION ./cmd/version_generated.go
- name: Build ${{ env.SNAP_NAME }} Snap for ${{ matrix.arch }}
id: build-snap
uses: snapcore/[email protected]
with:
snapcraft-args: remote-build --build-for=${{ matrix.arch }} --launchpad-accept-public-upload
- uses: actions/upload-artifact@v3
if: failure()
with:
name: snapcraft-logs
path: |
~/.cache/snapcraft/log/
~/.local/state/snapcraft/log/
${{ env.SNAP_NAME }}_*.txt
- name: Attach ${{ steps.build-snap.outputs.snap }} to GH workflow execution
uses: actions/upload-artifact@v3
if: steps.build-snap.outcome == 'success'
with:
name: ${{ steps.build-snap.outputs.snap }}
path: ${{ steps.build-snap.outputs.snap }}
test:
runs-on: ubuntu-latest
needs: [local-build, remote-build]
env:
# Testing is only enabled on amd64. We can add arm64 once we have such runners.
TEST_ON: amd64
if: |
always() &&
(needs.local-build.result == 'success' || needs.local-build.result == 'skipped') &&
(needs.remote-build.result == 'success' || needs.remote-build.result == 'skipped')
steps:
- uses: actions/download-artifact@v3
- id: get-snap
run: echo "filename=$(find ${{ env.SNAP_NAME }}*${{ env.TEST_ON }}*snap/*)" >> $GITHUB_OUTPUT
- name: Install and test ${{ steps.get-snap.outputs.filename }}
run: |
set -ex
sudo snap install --dangerous --classic ${{ steps.get-snap.outputs.filename }}
# Make sure it is installed
pebble version --client
# Run smoke test
pebble enter --create-dirs exec echo Hello | grep Hello
release:
runs-on: ubuntu-latest
needs: [test]
if: github.event_name != 'pull_request' && needs.test.result == 'success' && always()
strategy:
fail-fast: false
matrix:
arch: ["amd64", "arm64", "ppc64el", "armhf", "s390x"]
steps:
- uses: actions/download-artifact@v3
- id: get-snap
run: echo "filename=$(find ${{ env.SNAP_NAME }}*${{ matrix.arch }}*snap/*)" >> $GITHUB_OUTPUT
- name: Release ${{ steps.get-snap.outputs.filename }} to ${{ env.DEFAULT_TRACK }}/${{ env.DEFAULT_RISK }}
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
with:
snap: ${{ steps.get-snap.outputs.filename }}
release: ${{ env.DEFAULT_TRACK }}/${{ env.DEFAULT_RISK }}
promote:
runs-on: ubuntu-latest
needs: [release]
if: github.event_name == 'release' && needs.release.result == 'success' && always()
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64, ppc64el, armhf, s390x]
env:
TO_TRACK: latest
TO_RISK: candidate
steps:
- name: Install Snapcraft
run: sudo snap install snapcraft --classic
- name: Get current ${{ matrix.arch }} ${{ env.SNAP_NAME }} snap in ${{ env.TO_TRACK }}/${{ env.TO_RISK }}
id: get-snap
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
run: |
revision="$(snapcraft status ${{ env.SNAP_NAME }} \
--track ${{ env.DEFAULT_TRACK }} --arch ${{ matrix.arch }} \
| grep "${{ env.DEFAULT_RISK }}" | awk -F' ' '{print $3}')"
echo "revision=$revision" >> $GITHUB_OUTPUT
# It would be easier to use `snapcraft promote`, but there's an error when trying
# to avoid the prompt with the "--yes" option:
# > 'latest/edge' is not a valid set value for --from-channel when using --yes.
- name: Promote ${{ env.SNAP_NAME }} snap rev${{ steps.get-snap.outputs.revision }} to ${{ env.TO_TRACK }}/${{ env.TO_RISK }}
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
run: |
snapcraft release ${{ env.SNAP_NAME }} \
${{ steps.get-snap.outputs.revision }} \
${{ env.TO_TRACK }}/${{ env.TO_RISK }}