Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
1b73865
decouple app from other classes, stop using global "App" where possible
patinthehat Aug 18, 2023
f59ac77
remove deprecated ioutil calls
patinthehat Aug 18, 2023
7a1b1d2
remove duplicate function call
patinthehat Aug 18, 2023
c864e0b
code cleanup
patinthehat Aug 18, 2023
6405bba
code cleanup
patinthehat Aug 18, 2023
01ce77d
minor bug fixes and code cleanup
patinthehat Aug 18, 2023
96b1781
refactor gateway middleware into separate files
patinthehat Aug 18, 2023
2c84bb7
add initial unit tests for gateway package
patinthehat Aug 18, 2023
22fdf94
update tests workflow to upload coverage to codecov, implement minor …
patinthehat Aug 18, 2023
471c140
minor typo fix
patinthehat Aug 18, 2023
516502c
fix path to lib directory
patinthehat Aug 18, 2023
4089035
only run tests workflow on push for main branch or tagged releases
patinthehat Aug 18, 2023
39f209f
wip
patinthehat Aug 18, 2023
0d124d0
wip
patinthehat Aug 18, 2023
47f5dd0
refactor gateway verify filetype middleware, wip
patinthehat Aug 18, 2023
59bbbe7
implement a different, better glob package for domain matching
patinthehat Aug 18, 2023
6b55f6d
refactoring
patinthehat Aug 19, 2023
dfbce03
refactoring
patinthehat Aug 19, 2023
5aa744c
update config file generated by init command
patinthehat Aug 19, 2023
b7186f5
update readme
patinthehat Aug 19, 2023
881d2a3
update readme, minor adjustments
patinthehat Aug 19, 2023
62f0fe2
refactoring
patinthehat Aug 19, 2023
aef3472
minor additions
patinthehat Aug 19, 2023
1277341
refactoring
patinthehat Aug 19, 2023
db50a4a
refactoring
patinthehat Aug 19, 2023
b86fb5b
refactoring
patinthehat Aug 19, 2023
6afac8a
refactoring - move running of preconditions to precondition class
patinthehat Aug 19, 2023
c6d3a77
wip
patinthehat Aug 19, 2023
142d3c3
refactoring
patinthehat Aug 19, 2023
3e10872
reword example for includes section so it does not cause scrolling wh…
patinthehat Aug 19, 2023
e39d75f
minor updates
patinthehat Aug 19, 2023
13c6624
fix gateway crashes
patinthehat Aug 19, 2023
3f730c0
make test build and running tests separate jobs to run in parallel
patinthehat Aug 19, 2023
1603b02
taskfile optimizations and updates
patinthehat Aug 19, 2023
88bfcc1
wip
patinthehat Aug 20, 2023
ae3eb7c
refactoring, add unit tests for cache
patinthehat Aug 20, 2023
2834cbd
refactoring
patinthehat Aug 20, 2023
f488816
refactoring, add unit tests for utils
patinthehat Aug 20, 2023
24dcccb
refactoring
patinthehat Aug 20, 2023
1a995ff
wip
patinthehat Aug 20, 2023
de9a0ab
refactoring
patinthehat Aug 21, 2023
48f480e
refactoring
patinthehat Aug 21, 2023
e5a4606
update cache class to return nil when .Get() is called for an expured…
patinthehat Aug 21, 2023
10f96ba
wip
patinthehat Aug 21, 2023
31c284f
wip
patinthehat Aug 21, 2023
1917aa2
refactoring
patinthehat Aug 21, 2023
7c6c2d1
refactoring
patinthehat Aug 22, 2023
5b106c6
refactoring, add unit tests for WorkflowInclude class
patinthehat Aug 22, 2023
74cbfa6
reorganize files to avoid cyclic deps
patinthehat Aug 22, 2023
52a4631
refactoring
patinthehat Aug 22, 2023
faa85e1
refactoring
patinthehat Aug 22, 2023
01288cf
refactoring
patinthehat Aug 22, 2023
c6a5cd1
sync with main.go code
patinthehat Aug 25, 2023
5e5374a
refactoring
patinthehat Aug 25, 2023
c05705e
refactoring
patinthehat Aug 25, 2023
bacff3a
refactoring
patinthehat Aug 25, 2023
c6eeaa0
refactoring, add gateway caching of url responses, remove updater cac…
patinthehat Aug 25, 2023
0ab5b33
update checksums
patinthehat Aug 25, 2023
4c0d009
refactoring, wip
patinthehat Aug 25, 2023
f43e741
refactoring, wip
patinthehat Aug 26, 2023
35f209a
refactoring, adding tests, wip
patinthehat Aug 26, 2023
840c9d8
use go 1.20
patinthehat Aug 26, 2023
d670135
wip
patinthehat Aug 27, 2023
63d6760
fix typos
patinthehat Aug 27, 2023
33400da
refactoring, wip
patinthehat Aug 27, 2023
8a0dc83
temp disab;e notifications integrations
patinthehat Aug 27, 2023
a32e47d
temp disab;e notifications integrations
patinthehat Aug 27, 2023
95a1bdc
fix typo in filename
patinthehat Aug 27, 2023
8b51760
implement a basic state machine for checksum verification state, impl…
patinthehat Aug 28, 2023
4c5eb79
remove unused code
patinthehat Aug 30, 2023
099cef3
organize scripting extensions
patinthehat Aug 30, 2023
0e49826
code cleanup
patinthehat Aug 30, 2023
638953c
refactor and reorganizing, wip
patinthehat Aug 30, 2023
8bafc20
wip
patinthehat Aug 30, 2023
90968ff
refactoring
patinthehat Aug 30, 2023
db83639
refactoring
patinthehat Aug 30, 2023
2d6081c
update taskfile
patinthehat Aug 30, 2023
5d9a000
remove unused files
patinthehat Aug 30, 2023
bec455b
refactoring, remove unused code
patinthehat Aug 30, 2023
bf42e0e
refactoring
patinthehat Aug 31, 2023
a4953a3
add example .env file
patinthehat Aug 31, 2023
52a7d8c
optimize taskfile tasks, remove unused code
patinthehat Aug 31, 2023
81f9da5
update workflows, dependabot config
patinthehat Aug 31, 2023
0ee5c8e
add github action linter to lint task
patinthehat Aug 31, 2023
01295e4
update taskfile
patinthehat Aug 31, 2023
82cbcfc
fix linting issues with pre-commit hook, add shellcheck to lint custo…
patinthehat Aug 31, 2023
ad7bf70
fix broken tests
patinthehat Aug 31, 2023
1a6894c
refactoring
patinthehat Aug 31, 2023
b032296
update init command to use remote template file and text templating
patinthehat Aug 31, 2023
6aaaf63
minor fixes
patinthehat Aug 31, 2023
1533e76
implement interfaces for Application, refactoring, wip
patinthehat Aug 31, 2023
cf860b2
add test task
patinthehat Aug 31, 2023
471eeff
Merge branch 'main' into refactor-1
patinthehat Aug 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 11 additions & 45 deletions .custom-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,52 +1,18 @@
#!/usr/bin/env sh

# # Redirect output to stderr.
# exec 1>&2
PROJECT_BASE_PATH=$(git rev-parse --show-toplevel)
cd "$PROJECT_BASE_PATH" || exit 0

# # Check for unstaged changes to tracked files.
# echo "Checking for unstaged changes to tracked files..."
# if git diff --exit-code --quiet --ignore-submodules --cached
# then
# # No unstaged changes to tracked files, so we can proceed.
# echo "No unstaged changes detected."
# else
# # Unstaged changes to tracked files. We should stash them.
# echo "Stashing unstaged changes to tracked files..."
# git stash --keep-index --include-untracked
# fi
GO_FILES_STAGED=$(git diff --name-only --cached | grep -c .go)

# # Run golangci-lint on the staged files.
# echo "Running golangci-lint on staged files..."
# STAGED_GO_FILES=$(git diff --cached --name-only -- '*.go')
# if [ "$STAGED_GO_FILES" != "" ]
# then
# # Run golangci-lint on the staged files.
# golangci-lint run $STAGED_GO_FILES
# LINT_EXIT_CODE=$?
# else
# # No Go files staged.
# echo "No Go files staged for commit."
# LINT_EXIT_CODE=0
# fi
if [ -n "$GO_FILES_STAGED" ] && [ "$GO_FILES_STAGED" != "0" ]; then
GOLINT_BIN=$(which golangci-lint)

# # Unstash changes to tracked files, if necessary.
# if [ "$STASH_NAME" != "" ]
# then
# echo "Unstashing unstaged changes to tracked files..."
# git stash pop
# fi
if [ -n "$GOLINT_BIN" ]; then
LAST_COMMIT=$(git rev-parse HEAD)

# # If the linter failed (non-zero exit code), exit with a failure status.
# if [ $LINT_EXIT_CODE != 0 ]
# then
# echo "golangci-lint found issues in the staged files."
# exit 1
# fi
echo "[pre-commit] $GOLINT_BIN run -c ./.golangci.yaml --new-from-rev $LAST_COMMIT"

# Otherwise, exit with a success status.
exit 0

# GO_FILES_STAGED=$(git diff --name-only --cached | grep .go | wc -l)
# if [ ! -z $GO_FILES_STAGED ]; then
# golangci-lint run -c ./.golangci.yaml
# fi
$GOLINT_BIN run -c ./.golangci.yaml --new-from-rev "$LAST_COMMIT"
fi
fi
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FRONTEND_PROJECT_PATH=
LOCAL_BACKEND_PROJECT_PATH=

TELEGRAM_API_KEY=
TELEGRAM_CHAT_ID_1=
TELEGRAM_CHAT_ID_2=

SLACK_CHANNEL_1=
SLACK_WEBHOOK_URL=
13 changes: 0 additions & 13 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,9 @@ updates:
open-pull-requests-limit: 10
schedule:
interval: weekly
groups:
dev-dependencies:
- '*'
dependencies:
- '*'
labels:
- "dependencies"
allow:
- dependency-type: "direct"

- package-ecosystem: "github-actions"
directory: "/"
open-pull-requests-limit: 10
schedule:
interval: weekly
labels:
- "dependencies"
allow:
- dependency-type: "direct"
64 changes: 43 additions & 21 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
name: build
name: build-and-test
on:
push:
branches: [main]
branches:
- main
tags:
- 'v*'
- v*
pull_request:
pull_request_target:
types: [opened, edited]

jobs:
build:
strategy:
matrix:
go-version: [~1.20]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
env:
GO_VERSION: "~1.20"
GO111MODULE: "on"

env:
GO111MODULE: "on"
jobs:
test-build:
runs-on: ubuntu-latest

steps:

- name: Install Task
uses: arduino/setup-task@v1

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: ./go.sum
go-version: ${{ env.GO_VERSION }}

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

- name: Download Go modules
run: go mod download
- name: Download and tidy Go modules
run: task mod

- name: Build Application
id: build
run: task build
run: task build-stackup

run-tests:
runs-on: ubuntu-latest

- name: Run Tests
steps:
- name: Install Task
uses: arduino/setup-task@v1

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

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

- name: Download and tidy Go modules
run: task mod

- name: Run Tests with Coverage
run: go test -cover -coverprofile coverage.out -v ./lib/**

- name: Upload coverage reports to Codecov
if: ${{success()}}
run: go test ./...
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
11 changes: 2 additions & 9 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@ jobs:
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Auto-merge Dependabot PRs for semver-minor updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge Dependabot PRs for semver-patch updates
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
- name: Auto-merge Dependabot PRs
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/run-goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
runs-on: ubuntu-latest

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false

steps:
Expand Down
21 changes: 5 additions & 16 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
run:
# Timeout for analysis, e.g. 30s, 5m. Default: 1m
timeout: 15s
modules-download-mode: mod
modules-download-mode: readonly

# Include test files or not. Default: true
tests: false
tests: true

# Which dirs to skip: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path.
Expand All @@ -30,29 +30,20 @@ run:
# we confidently recognize autogenerated files.
# If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work on Windows.
skip-files:
- tools/*.go
- tools/configure/*.go

# Allow multiple parallel golangci-lint instances running; If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: true
concurrency: 4

concurrency: 8

linters:
disable-all: true
fast: true
disable:
- errcheck
- gosimple
- nestif
- staticcheck
- typecheck
- unused
enable:
- gocyclo
- govet
- maintidx
- misspell
- unused
- unparam
#- errcheck
#- funlen
Expand All @@ -72,7 +63,6 @@ severity:
default-severity: warning
case-sensitive: false


linters-settings:
gocyclo:
min-complexity: 20
Expand All @@ -92,7 +82,6 @@ linters-settings:
G302: "0644" # Maximum allowed permissions mode for os.OpenFile and os.Chmod - Default: "0600"
G306: "0644" # Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile - Default: "0600"

# Show functions with maintainability index lower than N. A high index indicates better maintainability (opposite of complexity). - Default: 20
maintidx:
under: 25

Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Spin up your entire dev stack with one command.
- [Initialization Script](#initialization-script)
- [Setup](#setup)
- [Building the project](#building-the-project)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Credits](#credits)
Expand Down Expand Up @@ -196,11 +195,12 @@ settings:

The `domains` section of the configuration file is used to specify a list of domain names that can be accessed when downloading remote files
or including remote files. Wildcards are supported, such as `*.github.com`.
If the `domains` section is not specified, default values of `raw.githubusercontent.com` and `api.github.com` are used.
If the `domains` section is not specified, default values of `raw.githubusercontent.com` and `api.github.com` are used for the allow list,
and all other domains are blocked.

The `hosts` section of `domains` allows the configuration of headers to send with requests to specific hosts. Hostnames may be fully-qualified
hostnames, or may contain wildcards. For example, `*.githubusercontent.com` will match `raw.githubusercontent.com` and `gist.githubusercontent.com`.
If the `gateway` field is set to `allow`, the hostname will be added to the list of allowed domains automatically.
If the `gateway` field is set to `allow`, the hostname will be added to the list of allowed domains automatically, and defaults to `true`.

> The domain allow list is applied to all url access, including when `StackUp` checks to see if it is running the latest version,
> or when sending anonymous opt-in analytics.
Expand Down Expand Up @@ -295,16 +295,21 @@ Included files can be specified with either a relative or absolute pathname. Re

```yaml
includes:
# include a remote file from github
- url: gh:permafrost-dev/stackup/main/templates/remote-includes/containers.yaml
verify: false # optional, defaults to true

- url: gh:permafrost-dev/stackup/main/templates/remote-includes/node.yaml
headers:
- 'Authorization: token $GITHUB_TOKEN' # headers to send with the request, can be javascript if wrapped in double braces
# headers to send with the request, javascript must be wrapped in double braces
- 'Authorization: token $GITHUB_TOKEN'
- '{{ "X-Some-Header: " + getEnv("GITHUB_TOKEN") }}'

- file: python.yaml # includes a local file
# include a local file
- file: python.yaml

- url: s3:127.0.0.1:9000/stackup-includes/python.yaml # includes a file from a minio bucket
# include a remote file from a minio/s3 bucket
- url: s3:127.0.0.1:9000/stackup-includes/python.yaml
access-key: $S3_KEY # access key loaded from `.env` or `env` section
secret-key: $S3_SECRET # secret key env loaded from `.env` or `env` section
secure: false # optional, defaults to true
Expand Down Expand Up @@ -548,8 +553,8 @@ Many of the fields in a `Task` can be defined using javascript. To specify an ex
| `binaryExists()`| `name: string` | returns true if the specified binary exists in `$PATH`, otherwise false |
| `env()` | `name: string` | returns the string value of environment variable `name |
| `exists()` | `filename: string` | returns true if `filename` exists, false otherwise |
| `fetch()` | `url: string` | returns the contents of the url `url` as a string |
| `fetchJson()`| `url: string` | returns the contents of the url `url` as a JSON object |
| `fetch()` | `url: string` | returns the contents of the url `url` as a string; gateway rules apply |
| `fetchJson()`| `url: string` | returns the contents of the url `url` as a JSON object; gateway rules apply |
| `fileContains()`| `filename: string, search: string` | returns true if `filename` contains `search`, false otherwise |
| `getCwd()` | -- | returns the directory stackup was run from |
| `hasEnv()` | `name: string` | returns true if the specified environment variable exists, otherwise false |
Expand All @@ -561,7 +566,6 @@ Many of the fields in a `Task` can be defined using javascript. To specify an ex
| `semver()` | `version: string` | returns a `SemVer` object based on the value of `version` |
| `statusMessage()` | `message: string` | prints a status message to stdout, without a trailing new line |
| `task()` | `taskId: string` | returns a `Task` object with the id `taskId` |
| `workflow()` | -- | returns a `Workflow` object |
| `app.FailureMessage()` | `message: string` | prints a failure message with an X to stdout with a trailing new line |
| `app.StatusLine()` | `message: string` | prints a status message to stdout, with a trailing new line |
| `app.StatusMessage()` | `message: string` | prints a status message to stdout, without a trailing new line |
Expand Down Expand Up @@ -731,18 +735,14 @@ go mod tidy

## Building the project

`stackup` uses [task](https://github.com/go-task/task) for running tasks, which is a tool similar to `make`.
`StackUp` uses [task](https://github.com/go-task/task) for running tasks, which is a tool similar to `make`.

```bash
task build
```

---

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
Expand Down
Loading