Skip to content

Commit

Permalink
Merge pull request #1490 from urfave/maint-build-cleanups
Browse files Browse the repository at this point in the history
Move more functionality into internal/build/build.go
  • Loading branch information
meatballhat authored Sep 12, 2022
2 parents 375e5df + a425337 commit 69f4122
Show file tree
Hide file tree
Showing 6 changed files with 565 additions and 200 deletions.
113 changes: 37 additions & 76 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Run Tests

on:
push:
branches:
Expand All @@ -9,10 +8,8 @@ on:
pull_request:
branches:
- main

permissions:
contents: read

jobs:
test:
strategy:
Expand All @@ -22,84 +19,53 @@ jobs:
name: ${{ matrix.os }} @ Go ${{ matrix.go }}
runs-on: ${{ matrix.os }}
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Set PATH
run: echo "${GITHUB_WORKSPACE}/.local/bin" >>"${GITHUB_PATH}"

- name: install goimports
if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: GOBIN=${PWD}/.local/bin go install golang.org/x/tools/cmd/goimports@latest

- name: Checkout Code
uses: actions/checkout@v3

- name: goimports check
if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: test -z $(goimports -l .)

- name: vet
run: go run internal/build/build.go vet

- name: test with urfave_cli_no_docs tag
run: go run internal/build/build.go -tags urfave_cli_no_docs test

- name: test
run: go run internal/build/build.go test

- name: test urfave-cli-genflags
run: make -C cmd/urfave-cli-genflags

- name: check-binary-size
run: go run internal/build/build.go check-binary-size

- name: check-binary-size with tags (informational only)
run: go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size

- name: Upload coverage to Codecov
if: success() && matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
- uses: actions/checkout@v3
- if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: make ensure-goimports
- if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: make lint
- run: make vet
- run: make test
env:
GFLAGS: -tags urfave_cli_no_docs
- run: make test
- run: make -C cmd/urfave-cli-genflags
- run: make check-binary-size
env:
GFLAGS: -tags urfave_cli_no_docs
- run: make check-binary-size
- run: make yamlfmt
- run: make diffcheck
- if: matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
run: make v2diff
- if: success() && matrix.go == '1.19.x' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

test-docs:
name: test-docs
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19.x

- name: Use Node.js 16
uses: actions/setup-node@v3
- uses: actions/setup-node@v3
with:
node-version: '16'

- name: Set PATH
run: echo "${GITHUB_WORKSPACE}/.local/bin" >>"${GITHUB_PATH}"

- name: Checkout Code
uses: actions/checkout@v3

- name: Install Dependencies
run: |
mkdir -p "${GITHUB_WORKSPACE}/.local/bin"
curl -fsSL -o "${GITHUB_WORKSPACE}/.local/bin/gfmrun" "https://github.com/urfave/gfmrun/releases/download/v1.3.0/gfmrun-$(go env GOOS)-$(go env GOARCH)-v1.3.0"
chmod +x "${GITHUB_WORKSPACE}/.local/bin/gfmrun"
- name: gfmrun
run: go run internal/build/build.go gfmrun --walk docs/v2/

- name: diff check
run: |
git diff --exit-code
git diff --cached --exit-code
- uses: actions/checkout@v3
- run: make ensure-gfmrun
- run: make gfmrun
env:
FLAGS: --walk docs/v2/
- run: make diffcheck
publish:
permissions:
contents: write
Expand All @@ -108,18 +74,13 @@ jobs:
needs: [test-docs]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup mkdocs
run: |
pip install -U pip
pip install -r mkdocs-requirements.txt
git remote rm origin
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/urfave/cli.git
- name: Publish Docs
run: |
mkdocs gh-deploy --force
- run: make ensure-mkdocs
env:
FLAGS: --upgrade-pip
- run: make set-mkdocs-remote
env:
MKDOCS_REMOTE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: make deploy-mkdocs
22 changes: 4 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,23 @@
# are very important so that maintainers and contributors can focus their
# attention on files that are primarily Go.

GO_RUN_BUILD := go run internal/build/build.go

.PHONY: all
all: generate vet tag-test test check-binary-size tag-check-binary-size gfmrun v2diff
all: generate vet tag-test test check-binary-size tag-check-binary-size gfmrun yamlfmt v2diff

# NOTE: this is a special catch-all rule to run any of the commands
# defined in internal/build/build.go with optional arguments passed
# via GFLAGS (global flags) and FLAGS (command-specific flags), e.g.:
#
# $ make test GFLAGS='--packages cli'
%:
go run internal/build/build.go $(GFLAGS) $* $(FLAGS)

.PHONY: tag-test
tag-test:
go run internal/build/build.go -tags urfave_cli_no_docs test

.PHONY: tag-check-binary-size
tag-check-binary-size:
go run internal/build/build.go -tags urfave_cli_no_docs check-binary-size

.PHONY: gfmrun
gfmrun:
go run internal/build/build.go gfmrun docs/v2/manual.md
$(GO_RUN_BUILD) $(GFLAGS) $* $(FLAGS)

.PHONY: docs
docs:
mkdocs build

.PHONY: docs-deps
docs-deps:
pip install -r mkdocs-requirements.txt

.PHONY: serve-docs
serve-docs:
mkdocs serve
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ following `make` targets may be used if desired:

```sh
# install documentation dependencies with `pip`
make docs-deps
make ensure-mkdocs
```

```sh
Expand Down
19 changes: 9 additions & 10 deletions flag-spec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# NOTE: this file is used by the tool defined in
# ./cmd/urfave-cli-genflags/main.go which uses the
# `Spec` type that maps to this file structure.

flag_types:
bool:
bool:
struct_fields:
- name: Count
- name: Count
type: int
pointer: true
float64:
float64:
Float64Slice:
value_pointer: true
skip_interfaces:
Expand All @@ -33,18 +32,18 @@ flag_types:
struct_fields:
- name: Base
type: int
UintSlice:
UintSlice:
value_pointer: true
skip_interfaces:
- fmt.Stringer
uint64:
struct_fields:
- name: Base
type: int
Uint64Slice:
Uint64Slice:
value_pointer: true
skip_interfaces:
- fmt.Stringer
- fmt.Stringer
string:
struct_fields:
- name: TakesFile
Expand All @@ -56,12 +55,12 @@ flag_types:
struct_fields:
- name: TakesFile
type: bool
time.Duration:
time.Duration:
Timestamp:
value_pointer: true
struct_fields:
- name: Layout
type: string
- name: Layout
type: string
- name: Timezone
type: "*time.Location"
Generic:
Expand Down
Loading

0 comments on commit 69f4122

Please sign in to comment.