Skip to content

Commit

Permalink
Merge pull request #9 from dolfolife/add-code-coverage
Browse files Browse the repository at this point in the history
Add Codecov settings and upload all files we use including files with no `_test.go`.
  • Loading branch information
dolfolife authored Sep 24, 2023
2 parents 4ad887a + c4e0baf commit ab11bd8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 9 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
name: Release CLI

on:
push:
branches:
- main
paths:
- 'pkg/**'
- 'cmd/**'
- 'go.*'
- 'main.go'
workflow_run:
workflows: ["Test AoCTL"]
branches: [main]
types:
- completed

env:
REGISTRY: ghcr.io
jobs:
goreleaser:
release:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -34,6 +33,14 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4

- name: Test
run: go test ./... -cover

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Create new tag
run: |
tag=$(echo $(git describe --abbrev=0 --tags) | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test AoCTL

on:
pull_request:
branches:
- main
push:
branches:
- main
paths:
- 'pkg/**'
- 'cmd/**'
- 'go.*'
- 'main.go'

jobs:
test-cli:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4

- name: Test
env:
GOEXPERIMENT: nocoverageredesign
run: go test ./pkg/... ./cmd/... -coverpkg=./pkg/...,./cmd/... -coverprofile=coverage.out

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
dist/
coverage*
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Advent of Code CLI

[![Go Reference](https://pkg.go.dev/badge/github.com/dolfolife/aoctl#section-readme.svg)](https://pkg.go.dev/github.com/dolfolife/aoctl#section-readme)
[![codecov](https://codecov.io/github/dolfolife/aoctl/graph/badge.svg?token=GTFZX1J2WX)](https://codecov.io/github/dolfolife/aoctl)

This is a personal project I have to learn more about writing CLI tools in GoLang. The idea behind this project is to help me solve the [Advent of Code](adventofcode.com/) since I have noticed some patterns while solving them.

Expand Down

0 comments on commit ab11bd8

Please sign in to comment.