Skip to content

Commit

Permalink
[Tooling] Act helpers to run github workflows locally (#341)
Browse files Browse the repository at this point in the history
Adding some makefile helpers to streamline the usage of [act](https://github.com/nektos/act) on the team.

@h5law shared it on our discord channel and does make it easier to verify things locally.

![Screenshot 2024-01-22 at 1 54 41 PM](https://github.com/pokt-network/poktroll/assets/1892194/58d8f958-abda-4eb5-b409-0a4845f4d72b)
  • Loading branch information
Olshansk authored Jan 23, 2024
1 parent a3a2c80 commit 8d3f4a9
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ check_go_version:
exit 1; \
fi

.PHONY: check_act
# Internal helper target - check if `act` is installed
check_act:
{ \
if ( ! ( command -v act >/dev/null )); then \
echo "Seems like you don't have `act` installed. Please visit https://github.com/nektos/act before continuing"; \
exit 1; \
fi; \
}

.PHONY: check_gh
# Internal helper target - check if `gh` is installed
check_gh:
{ \
if ( ! ( command -v gh >/dev/null )); then \
echo "Seems like you don't have `gh` installed. Please visit https://cli.github.com/ before continuing"; \
exit 1; \
fi; \
}


.PHONY: check_docker
# Internal helper target - check if docker is installed
check_docker:
Expand Down Expand Up @@ -560,3 +581,32 @@ docusaurus_start: check_npm check_node ## Start the Docusaurus server
.PHONY: poktrolld_addr
poktrolld_addr: ## Retrieve the address for an account by ACC_NAME
@echo $(shell poktrolld --home=$(POKTROLLD_HOME) keys show -a $(ACC_NAME))


###################
### Act Helpers ###
###################

.PHONY: detect_arch
# Internal helper to avoid the caller needing to specify the architecture
detect_arch:
@ARCH=`uname -m`; \
case $$ARCH in \
x86_64) \
echo linux/amd64 ;; \
arm64) \
echo linux/arm64 ;; \
*) \
echo "Unsupported architecture: $$ARCH" >&2; \
exit 1 ;; \
esac

.PHONY: act_list
act_list: check_act ## List all github actions that can be executed locally with act
act --list

.PHONY: act_reviewdog
act_reviewdog: check_act check_gh ## Run the reviewdog workflow locally like so: `GITHUB_TOKEN=$(gh auth token) make act_reviewdog`
$(eval CONTAINER_ARCH := $(shell make -s detect_arch))
@echo "Detected architecture: $(CONTAINER_ARCH)"
act -v -s GITHUB_TOKEN=$(GITHUB_TOKEN) -W .github/workflows/reviewdog.yml --container-architecture $(CONTAINER_ARCH)

0 comments on commit 8d3f4a9

Please sign in to comment.