Skip to content

Commit

Permalink
add start of github action
Browse files Browse the repository at this point in the history
  • Loading branch information
tateexon committed Jul 31, 2024
1 parent d10c11a commit 70a5312
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @tateexon
61 changes: 61 additions & 0 deletions .github/actions/go-change-delta/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: 'Update Internal Mirrors Action'
inputs:
version:
description: The go-change-delta version you wish to use
required: false
default: latest
install:
description: Should we install go-change-delta
required: false
default: 'true'
use-nix:
description: Should nix be used under the hood, requires this projects load-nix action
required: false
default: 'false'
base-ref:
description: The base ref to compare results against, typically this is main
required: false
default: ${{ github.base_ref }}
depth:
description: The depth of recursion to check, 0 is default and infinite and will get all packages at any depth
required: false
default: '0'
path:
description: The path to the root of the go module, if this is a a go module not at the root this is helpful
required: false
default: ""
exclude:
description: A comma separated list of paths to exclude from the checks
required: false
default: ""
include-test:
description: Should include test only package changes
required: false
default: true
outputs:
packages:
description: Affected Packages
value: ${{ steps.delta.outputs.packages || '' }}
runs:
using: 'composite'
steps:
- name: Install go-change-delta
if: inputs.install == 'true'
shell: bash
run: |
if [ "${{ inputs.use-nix }}" == "false" ]; then
go install github.com/tateexon/go-change-delta@${{ inputs.version }}
else
nix develop -c sh -c "go install github.com/tateexon/go-change-delta@${{ inputs.version }}"
fi
- name: Get Packages Delta
id: delta
shell: bash
run: |
packages=""
if [ "${{ inputs.use-nix }}" == "false" ]; then
packages=$(go-change-delta -b=${{inputs.base-ref}} -l=${{inputs.depth}} -p=${{inputs.path}} -e=${{inputs.exclude}} -t=${{inputs.include-test}})
else
packages=$(nix develop -c -sh "go-change-delta -b=${{inputs.base-ref}} -l=${{inputs.depth}} -p=${{inputs.path}} -e=${{inputs.exclude}} -t=${{inputs.include-test}}")
fi
echo "packages=${packages}" >> $GITHUB_OUTPUT
13 changes: 13 additions & 0 deletions .github/actions/load-nix/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Load Nix
description: Load nix and setup a cleaner alias on `n` to run bash from within nix
runs:
using: 'composite'
steps:
- name: Install Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Pre-Load Nix
shell: bash
run: |
nix develop -c sh -c "echo \"load\""
9 changes: 5 additions & 4 deletions .github/workflows/ci.yaml → .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # needed for pre-commit to work correctly
- name: Install Nix
uses: cachix/install-nix-action@ba0dd844c9180cbf77aa72a116d6fbc515d0e87b # v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Load Nix
uses: ./.github/actions/load-nix
- name: Validate Pre-Commit Config
shell: bash
run: nix develop -c sh -c "pre-commit validate-config"
- name: Run pre-commit checks
env:
BASE_REF: ${{ github.base_ref }}
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test
on:
push:
branches:
- main
pull_request:

jobs:
pre-commit:
name: Run Go Tests
runs-on: ubuntu-latest
steps:
- name: Checkout the Repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0 # needed for pre-commit to work correctly
- name: Load Nix
uses: ./.github/actions/load-nix
- name: Get Affected Packages
uses: ./.github/actions/go-change-delta
id: delta
with:
use-nix: 'true'
- name: Run Tests
run: nix develop -c sh -c "go test -timeout 5m -cover -covermode=count ${{ steps.delta.outputs.packages }}"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
go-change-delta
/go-change-delta
unit-test-coverage.out

0 comments on commit 70a5312

Please sign in to comment.