Skip to content

Commit

Permalink
makefile udpate (trustwallet#24647)
Browse files Browse the repository at this point in the history
* makefile udpate

* only run fix all for trustwallet org, fix-dryrun is executed for forks

* update codeql workflow
  • Loading branch information
vorotech authored Apr 12, 2023
1 parent 2244f47 commit b18deb4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 53 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,8 @@ jobs:
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Build assets binary
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Expand Down
24 changes: 7 additions & 17 deletions .github/workflows/fix.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
name: Fixes
# Runs on:
# - on master branch of trustwallet repo: fix, checkin
# - on other branch of trustwallet repo: fix, checkin
# - on fork repos: fix-sanity only
name: Fix All

on:
push:
branches:
- 'master'
- '*'
workflow_dispatch:

jobs:
fix-all:
runs-on: ubuntu-latest

if: github.repository_owner == 'trustwallet' && github.event.repository.fork == false

steps:
- name: Checkout (trustwallet repo, secret token)
if: github.repository_owner == 'trustwallet'
uses: actions/checkout@v3
with:
# Use trust-ci fine-grained PAT to checkout and later commit the code
# Do not use for forked repos
token: ${{ secrets.CI_GITHUB_TOKEN }}
ref: ${{ github.ref }}

- name: Checkout (fork repo, default token)
if: github.repository_owner != 'trustwallet'
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.ref }}

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
id: go

- name: Run fix
if: github.repository_owner == 'trustwallet'
run: make fix

- name: Show fix result (diff)
Expand All @@ -53,4 +43,4 @@ jobs:
with:
commit_user_name: trust-ci
commit_user_email: "[email protected]"
commit_message: Fixes (sanity and consistency, auto)
commit_message: Auto fix all (sanity and consistency)
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
**/.DS_Store
node_modules/
.idea
.vscode/
*~
*.txt
.env
.env.test
bin/
vendor/
46 changes: 27 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
#! /usr/bin/make -f

# Project variables.
VERSION := $(shell git describe --tags 2>/dev/null || git describe --all)
BUILD := $(shell git rev-parse --short HEAD)
PROJECT_NAME := $(shell basename "$(PWD)")
BUILD_TARGETS := $(shell find cmd -name \*main.go | awk -F'/' '{print $$0}')

# Go related variables.
GOBASE := $(shell pwd)
GOBIN := $(GOBASE)/bin
# Use linker flags to provide version/build settings
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"

# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent

# Go files.
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)


# Common commands.
all: fmt lint test

build:
@echo " > Building main.go to bin/assets"
go build $(LDFLAGS) -o bin/assets ./cmd

test:
@echo " > Running unit tests"
GOBIN=$(GOBIN) go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./...
go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./...

fmt:
@echo " > Format all go files"
GOBIN=$(GOBIN) gofmt -w ${GOFMT_FILES}
gofmt -w ${GOFMT_FILES}

lint-install:
ifeq (,$(wildcard test -f bin/golangci-lint))
Expand All @@ -31,23 +40,22 @@ lint: lint-install
@echo " > Running golint"
bin/golangci-lint run --timeout=2m


# Assets commands.
check:
go run cmd/main.go check
check: build
bin/assets check

fix:
go run cmd/main.go fix
fix: build
bin/assets fix

update-auto:
go run cmd/main.go update-auto
update-auto: build
bin/assets update-auto

# Helper commands.
add-token:
go run cmd/main.go add-token $(asset_id)
add-token: build
bin/assets add-token $(asset_id)

add-tokenlist:
go run cmd/main.go add-tokenlist $(asset_id)
add-tokenlist: build
bin/assets add-tokenlist $(asset_id)

add-tokenlist-extended:
go run cmd/main.go add-tokenlist-extended $(asset_id)
add-tokenlist-extended: build
bin/assets add-tokenlist-extended $(asset_id)

0 comments on commit b18deb4

Please sign in to comment.