Skip to content

Commit

Permalink
Testing version stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoyt committed Jul 15, 2024
1 parent 4e6e89c commit 89e398e
Showing 1 changed file with 146 additions and 132 deletions.
278 changes: 146 additions & 132 deletions .github/workflows/snap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,31 @@ jobs:
with:
fetch-depth: 0

- 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 }}
- name: Test version stuff local
run: |
echo GITHUB_REF=$GITHUB_REF
echo GITHUB_REF_NAME=$GITHUB_REF_NAME
echo GITHUB_REF_TYPE=$GITHUB_REF_TYPE
git describe --tags --always
# - 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
Expand All @@ -62,118 +69,125 @@ jobs:
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: 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 }}
- name: Test version stuff remote
run: |
snapcraft release ${{ env.SNAP_NAME }} \
${{ steps.get-snap.outputs.revision }} \
${{ env.TO_TRACK }}/${{ env.TO_RISK }}
echo GITHUB_REF=$GITHUB_REF
echo GITHUB_REF_NAME=$GITHUB_REF_NAME
echo GITHUB_REF_TYPE=$GITHUB_REF_TYPE
git describe --tags --always
# - 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: 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 }}

0 comments on commit 89e398e

Please sign in to comment.