Skip to content

Commit

Permalink
feat: add Makefile for consistent behavior across samples (#3563)
Browse files Browse the repository at this point in the history
* feat: add Makefile for consistent behavior across samples

* fix default directory detection

* update lint action per discussion with Patti.

* fix project id env var name to match proposal

* fix lint error in unrelated sample

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Patti Shin <pattishin@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 27, 2023
1 parent 2c008f8 commit 73de2e8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Makefile for running typical developer workflow actions.
# To run actions in a subdirectory of the repo:
# make lint build dir=translate/snippets

INTERFACE_ACTIONS="build test lint"

.ONESHELL: #ease subdirectory work by using the same subshell for all commands
.-PHONY: *

# Default to current dir if not specified.
dir ?= $(shell pwd)

export GOOGLE_CLOUD_PROJECT = ${GOOGLE_SAMPLES_PROJECT}

build:
cd ${dir}
npm install
npm run build --if-present

test: check-env build
cd ${dir}
npm test

lint:
cd ${dir}
npx gts fix
npx gts lint

check-env:
ifndef GOOGLE_SAMPLES_PROJECT
$(error GOOGLE_SAMPLES_PROJECT environment variable is required to perform this action)
endif

list-actions:
@ echo ${INTERFACE_ACTIONS}

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
"gts": "^5.0.1",
"mocha": "^10.2.0",
"nunjucks": "^3.2.4",
"prettier": "^3.0.0",
"prettier": "^3.0.3",
"typescript": "^5.0.4"
},
"dependencies": {
"commander": "^11.0.0"
"commander": "^11.0.0",
"eslint": "^8.53.0"
}
}

0 comments on commit 73de2e8

Please sign in to comment.