Skip to content

Commit

Permalink
Add github actions for testing and releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
airhorns committed Nov 27, 2024
1 parent fcdd3e0 commit d774c2c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/actions/setup-test-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Setup test environment"
description: ""
inputs: {}
outputs: {}
runs:
using: "composite"
steps:
- uses: cachix/install-nix-action@v20
- run: |
source <(nix print-dev-env --show-trace)
output_file="nix-env.txt"
# Clear the output file
> $output_file
# Loop over each variable in the environment
while IFS='=' read -r -d '' name value; do
# Skip if the variable is a function or read-only or non-alphanumeric
[[ "$(declare -p $name)" =~ "declare -[a-z]*r[a-z]* " ]] && continue
[[ ! $name =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]] && continue
# Check if the variable value contains a newline
if [[ "$value" != *$'\n'* ]]; then
# It doesn't, so write the variable and its value (stripping quotes) to the file
echo "${name}=${value//\"/}" >> $output_file
fi
done < <(env -0)
# useful for debugging what env is exported
# cat nix-env.txt
shell: bash
- run: cat nix-env.txt >> "$GITHUB_ENV"
shell: bash
- name: Add Gadget npm registry
shell: bash
run: npm config set @gadget-client:registry https://registry.gadget.dev/npm
- name: Install dependencies with pnpm
shell: bash
run: pnpm install
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release
on:
push:
branches:
- main
paths:
- 'package.json'
workflow_dispatch:

jobs:
test:
uses: ./.github/workflows/test.yml
release:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-test-env
- id: npm-publish
name: Publish wds to npm
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
- name: Publish Release to github
uses: softprops/action-gh-release@v1
if: ${{ steps.npm-publish.outputs.type != 'none' }}
with:
tag_name: ${{ steps.npm-publish.outputs.version }}
generate_release_notes: true
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test

on:
push:
workflow_call:

jobs:
test:
timeout-minutes: 30
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-test-env
- run: pnpm build
- run: pnpm test

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-test-env
- run: pnpm lint

0 comments on commit d774c2c

Please sign in to comment.