Skip to content

Commit

Permalink
optimize taskfile tasks, remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Aug 31, 2023
1 parent a4953a3 commit 52a7d8c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 77 deletions.
75 changes: 14 additions & 61 deletions Taskfile.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ dotenv: ['.env', '.env.local']

vars:
APP_VERSION_FILE: './lib/version/app-version.go'
ENTRY_FILENAME: './app/main.go'
BUILD_OUTPUT_DIR: './dist'
BINARY_FILENAME: 'stackup'
DIST_TARGET_FILE: '{{.BUILD_OUTPUT_DIR}}/{{.BINARY_FILENAME}}'
DOTENV_FILES:
sh: find . -name ".env*" -print | sort -u | egrep -v '^./dist.*$' | tr '\n' ' '
DIST_TARGET_FILE: '{{.BUILD_OUTPUT_DIR}}/stackup'
ENTRY_FILENAME: './app/main.go'

tasks:

Expand All @@ -29,7 +26,7 @@ tasks:
- task: update-version-file
cmds:
- task: build-stackup
- task: copy-config-template-to-dist
- task: copy-config-files-to-dist

clean:
desc: Cleans up build artifacts
Expand All @@ -40,42 +37,18 @@ tasks:
- rm -f {{.DIST_TARGET_FILE}}

lint:
cmds:
- task: lint-dotenv
- task: lint-stackup
- task: lint-spell

update-version-file:
cmds:
- go run tools/generate-version-file.go

lint-dotenv:
desc: Lints all dotenv files
preconditions:
- which golangci-lint
- which dotenv-linter
cmds:
- dotenv-linter {{.DOTENV_FILES}}

lint-spell:
desc: Check for typos in filenames and source code
ignore_error: true
preconditions:
- which typos
vars:
SRC_DIRS:
sh: "/bin/ls -1F | grep '/' | egrep -v '(\\..+|build|dist|assets|tools)' | tr -s '\\n/' ' '"
cmds:
- typos ./lib ./templates ./README.md
- golangci-lint run
- dotenv-linter --not-check-updates --recursive
- typos

lint-stackup:
desc: Runs golangci-lint
vars:
SRC_DIRS:
sh: find . -name "*.go" -printf '%h\n' | awk -F/ '{ print "./" $2 }' | sort -u | grep -v './tools' | tr '\n' ' '
preconditions:
- which golangci-lint
update-version-file:
cmds:
- golangci-lint run {{.SRC_DIRS}}
- go run tools/generate-version-file.go

prepare-dist-folder:
desc: Prepares dist folder
Expand All @@ -92,46 +65,26 @@ tasks:
- task: prepare-dist-folder
sources:
- '{{.ENTRY_FILENAME}}'
- ./lib/**/*.go
- ./lib/*.go
generates:
- '{{.DIST_TARGET_FILE}}'
cmds:
- go build -trimpath -ldflags="-s -w -X main.Version={{.VERSION}}-{{.GIT_COMMIT}}" -o {{.DIST_TARGET_FILE}} {{.ENTRY_FILENAME}}

copy-config-template-to-dist:
copy-config-files-to-dist:
desc: Copies config template to dist folder
deps:
- task: prepare-dist-folder
cmds:
- cp -f ./templates/*.yaml {{.BUILD_OUTPUT_DIR}}

bump-minor-version-and-tag:
run: once
desc: Bumps minor version and creates a new git tag
preconditions:
- which svu
cmds:
- echo "bumping version to $(svu minor)"
- git tag $(svu minor)

release-new-minor-version:
desc: Create a new minor version release on github
cmds:
- task: bump-minor-version-and-tag
- task: update-version-file
- git push --tags
- cp -f ./.env {{.BUILD_OUTPUT_DIR}}

update-checksums:
dir: templates/remote-includes
cmds:
- sha256sum *.yaml > checksums.sha256.txt
- task: commit-updated-checksums

commit-updated-checksums:
desc: Commits updated checksum files
internal: true
silent: true
cmds:
- git add templates/remote-includes/checksums.*.txt
- git add checksums.sha256.txt
- git commit -m "update checksum files"

autobuild:
Expand Down
31 changes: 15 additions & 16 deletions lib/app/WorkflowInclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@ import (
)

type WorkflowInclude struct {
Url string `yaml:"url"`
Headers []string `yaml:"headers"`
File string `yaml:"file"`
ChecksumUrl string `yaml:"checksum-url"`
VerifyChecksum bool `yaml:"verify,omitempty"`
AccessKey string `yaml:"access-key"`
SecretKey string `yaml:"secret-key"`
Secure bool `yaml:"secure"`
identifierString string
ValidationState ChecksumVerificationState
Contents string
Hash string
FoundChecksum string
HashAlgorithm checksums.ChecksumAlgorithm
FromCache bool
Workflow *StackupWorkflow
Url string `yaml:"url"`
Headers []string `yaml:"headers"`
File string `yaml:"file"`
ChecksumUrl string `yaml:"checksum-url"`
VerifyChecksum bool `yaml:"verify,omitempty"`
AccessKey string `yaml:"access-key"`
SecretKey string `yaml:"secret-key"`
Secure bool `yaml:"secure"`
ValidationState ChecksumVerificationState
Contents string
Hash string
FoundChecksum string
HashAlgorithm checksums.ChecksumAlgorithm
FromCache bool
Workflow *StackupWorkflow
}

func expandUrlPrefixes(url string) string {
Expand Down

0 comments on commit 52a7d8c

Please sign in to comment.