Skip to content

Commit

Permalink
CI/CD tweaks (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Feb 13, 2023
1 parent 39e4505 commit 063bb94
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 85 deletions.
18 changes: 18 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: cache
runs:
using: "composite"
steps:
- run: |
case ${{ runner.os }} in
macOS)
echo "path=$HOME/Library/Caches/deno/deps" >> $GITHUB_OUTPUT;;
*)
echo "path=$HOME/.cache/deno" >> $GITHUB_OUTPUT;;
esac
id: cache
shell: bash
- uses: actions/cache@v3
with:
path: ${{ steps.cache.outputs.path }}
restore-keys: ${{ runner.os }}-deno-
key: ${{ runner.os }}-deno-${{ hashFiles('deno.jsonc')}}
85 changes: 40 additions & 45 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- main
paths:
- README.md
- .github/workflows/cd.yml
workflow_dispatch:

concurrency:
Expand All @@ -16,21 +15,20 @@ concurrency:
jobs:
check:
permissions:
contents: read
actions: write # for cancel-action
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tea.outputs.version }}
commence: ${{ steps.rev-parse.outputs.result == 'commence' }}
steps:
- uses: actions/checkout@v3

- uses: teaxyz/setup@v0
id: tea

- name: sanity
run: test -n "${{ steps.tea.outputs.version }}"
# check we’re not broken ^^
- name: sanity check
run: |
test -n "$(echo ${{ steps.tea.outputs.version }} | cut -f1 -d.)"
test -n "$(echo ${{ steps.tea.outputs.version }} | cut -f2 -d.)"
test -n "$(echo ${{ steps.tea.outputs.version }} | cut -f3 -d.)"
- id: rev-parse
name: did we already publish this version?
Expand Down Expand Up @@ -77,24 +75,17 @@ jobs:
steps:
- uses: actions/download-artifact@v3
with:
name: tarballs
path: artifacts
- run: tar xJvf artifacts/tea-${{ needs.check.outputs.version }}.tar.xz --strip-components=1
- run: ls -la
name: srcs
- run: tar xJf tea-${{ needs.check.outputs.version }}.tar.xz --strip-components=1
- uses: ./.github/actions/cache # avoids sporadic 500s from deno’s CDN
- uses: teaxyz/setup@v0
- run: deno task compile
- run: test "$(./tea --version)" = "tea ${{ needs.check.outputs.version }}"
- run: tar cJf tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz ./tea
- uses: actions/upload-artifact@v3
with:
name: tarballs
path: tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz
if-no-files-found: error
- run: mv ./tea tea-${{ matrix.platform.build-id }}
- run: tar cJf tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz tea
- uses: actions/upload-artifact@v3
with:
name: binaries
path: tea-${{ matrix.platform.build-id }}
path: tea-${{ needs.check.outputs.version }}+${{ matrix.platform.build-id }}.tar.xz
if-no-files-found: error

bundle-src:
Expand All @@ -106,12 +97,15 @@ jobs:
- uses: actions/checkout@v3
with:
path: ${{ env.FILENAME }}
- run: rm -rf ${{ env.FILENAME }}/.github .gitpod.yml
- run: echo "export default function() { return '${{ needs.check.outputs.version }}' }" > $FILENAME/src/hooks/useVersion.ts
#TODO restore this, but you’ll need to fix the use of action/cache above
# - name: Clean
# run: rm -rf ${{ env.FILENAME }}/.github .gitpod.yml
- name: Stamp Version
run: echo "export default function() { return '${{ needs.check.outputs.version }}' }" > $FILENAME/src/hooks/useVersion.ts
- run: tar cJf $FILENAME.tar.xz $FILENAME
- uses: actions/upload-artifact@v3
with:
name: tarballs
name: srcs
path: ${{ env.FILENAME }}.tar.xz
if-no-files-found: error

Expand All @@ -122,23 +116,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: tarballs
path: artifacts

# says `no changes` every time… 🤦🏼
# - uses: mikepenz/release-changelog-builder-action@v3
# id: build_changelog
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.check.outputs.version }}
files: artifacts/*
# body: ${{ steps.build_changelog.outputs.changelog }}
files: |
binaries/*
srcs/*
fail_on_unmatched_files: true

bump-tap:
Expand All @@ -161,22 +145,33 @@ jobs:
with:
name: binaries
path: binaries
- name: AWS credentials
uses: aws-actions/configure-aws-credentials@v1

- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Upload to S3

- name: Unpack Binaries
working-directory: binaries
run: |
aws s3 sync binaries s3://www.tea.xyz/ \
--metadata-directive REPLACE \
for filename in *.tar.xz; do
tar xJf $filename
result="${filename#*+}"
result="${filename%.tar.xz}"
mv tea ../tea-$result
done
- name: Upload to S3
run:
aws s3 sync tea-* s3://www.tea.xyz/
--metadata-directive REPLACE
--cache-control no-cache,must-revalidate
- run: find binaries -type f | sed 's/^binaries//'
- name: Invalidate cache

- name: Invalidate CloudFront
run:
find binaries -type f |
sed 's/^binaries//' |
find . -name tea-\* |
sed 's/^.//' |
xargs
aws cloudfront create-invalidation
--distribution-id ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
Expand All @@ -195,7 +190,7 @@ jobs:
wait-for-completion: false

vx-tagger:
needs: [upload-binaries]
needs: [upload-binaries, check]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.md.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI·markdown-lint

on:
pull_request:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/ci.sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI·sync

on:
pull_request:
paths:
- import-map.json
- src/hooks/app.sync.ts
- src/hooks/useSync.ts
- .github/workflows/ci.sync.yml

concurrency:
group: ${{ github.ref }}/sync
cancel-in-progress: true

jobs:
# in situations without `git` we had a softlock problem that we're testing for here
test-sync-lock:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
- runner: macos-latest
- runner: ubuntu-latest
container: debian:buster-slim
- runner: ubuntu-latest
container: archlinux:latest
container: ${{ matrix.platform.container }}
name: test sync-lock (${{ matrix.platform.container || matrix.platform.runner }})
steps:
# denoland/setup requires `unzip` to be installed
# https://github.com/denoland/setup-deno/issues/41
- name: ensure `unzip`
run: |
case "${{ matrix.platform.container }}" in
debian:buster-slim)
apt-get update && apt-get install unzip;;
archlinux:latest)
pacman -Sy --noconfirm unzip;;
esac
- uses: actions/checkout@v3
- uses: ./.github/actions/cache # avoids sporadic 500s from deno’s CDN
- uses: denoland/setup-deno@v1

- run: deno task --config $GITHUB_WORKSPACE/deno.jsonc compile
working-directory: /usr/local/bin

- run: tea -S +gnu.org/wget wget -L tea.xyz/white-paper/ | tea -S +charm.sh/glow glow -

# run again to test this work in the “update” scenario
- run: tea -S +gnu.org/wget wget -L tea.xyz/white-paper/ | tea -S +charm.sh/glow glow -
44 changes: 5 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,55 +24,21 @@ jobs:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
- uses: ./.github/actions/cache # avoids sporadic 500s from deno’s CDN
- uses: denoland/setup-deno@v1 # using ourself to install deno could compromise the tests
- run: deno task test

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: teaxyz/setup@v0
- run: tea deno lint src/*/**.ts
- run: deno lint src/*/**.ts

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/cache # avoids sporadic 500s from deno’s CDN
- uses: teaxyz/setup@v0
- run: tea deno task typecheck

# in situations without `git` we had a softlock problem that we're testing for here
test-sync-lock:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
- runner: macos-latest
- runner: ubuntu-latest
container: debian:buster-slim
- runner: ubuntu-latest
container: archlinux:latest
container: ${{ matrix.platform.container }}
name: test sync-lock (${{ matrix.platform.container || matrix.platform.runner }})
steps:
# denoland/setup requires `unzip` to be installed
# https://github.com/denoland/setup-deno/issues/41
- name: ensure `unzip`
run: |
case "${{ matrix.platform.container }}" in
debian:buster-slim)
apt-get update && apt-get install unzip;;
archlinux:latest)
pacman -Sy --noconfirm unzip;;
esac
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
- run: deno task --config $GITHUB_WORKSPACE/deno.jsonc compile
working-directory: /usr/local/bin

- run: tea -S +gnu.org/wget wget -L tea.xyz/white-paper/ | tea -S +charm.sh/glow glow -

# run again to test this work in the “update” scenario
- run: tea -S +gnu.org/wget wget -L tea.xyz/white-paper/ | tea -S +charm.sh/glow glow -
- run: deno task typecheck
1 change: 1 addition & 0 deletions .github/workflows/retagger.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
on:
release:
types:
- created
- edited
permissions:
actions: write
Expand Down

0 comments on commit 063bb94

Please sign in to comment.