Skip to content

Commit

Permalink
chore: addresses all the solid feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Gowiem committed Jul 25, 2023
1 parent e32a0e7 commit b92b39e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 26 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# Taskit

Taskit (said Task-kit or TK for short) is the Masterpoint [Taskfile](https://taskfile.dev/) Kit. We utilize this set of Taskfiles across clients as a means by which to share repeatable tasks like repo setup, tool automation, and similar shared scripting.
Taskit (said task-kit or TK for short) is the Masterpoint [Taskfile](https://taskfile.dev/) Kit. We utilize this set of Taskfiles across clients as a means by which to share repeatable tasks like repo setup, tool automation, and similar shared scripting.

## Using Taskit

Taskit is built around the idea of being consumed by downstream repos. It is pulled through a standard Taskfile that you can find in [`exports/Taskfile.dist.yaml`](./exports/Taskfile.dist.yaml).

The procedure to add it to a project is to do the following:

1. Copy `exports/Taskfile.dist.yaml` to your project.
2. Add the following lines to your project's `.gitignore`:
1. Copy `exports/Taskfile.dist.yaml` to your project by running the following command:

```gitignore
.taskit/
.task/
.snaplet/snapshots/
```bash
curl -sL https://raw.githubusercontent.com/masterpointio/taskit/main/exports/Taskfile.dist.yaml -o Taskfile.dist.yaml
```

3. Run `task init` to initialize taskit by downloading this repo into your remote repo. Note, `git` is a requirement.
4. Run `task --list` to list all newly available tasks from taskit.
5. (Optional) Add a `.env.taskit` file which can include overrides for any variables in taskit.
1. Run `task init` to initialize taskit by downloading this repo into your remote repo.
1. Note, `git` is a requirement.
1. Run `task --list` to list all newly available tasks from taskit.
1. (Optional) Add a `.env.taskit` file which can include overrides for any variables in taskit.
1. Now that the setup process for taskit is complete, you should commit and push the new configuration files to your repo. Well done 👏

## TODO

- [x] Upstream various tasks from our distributed usage
- [ ] Create a test harness + tests around tasks
- [ ] Upstream various tasks from our distributed usage
- [ ] Publish versions
38 changes: 30 additions & 8 deletions exports/Taskfile.dist.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the Taskfile responsible for managing Taskit in any consuming repository
# This is the Taskfile responsible for managing taskit in any consuming repository
# More information is available at https://github.com/masterpointio/taskit
# This file is typically copied into the repo as-is and any required edits should be made both here and in the taskit repo (if applicable)
# This file is typically cloned into the repo as-is and any required edits should be made both here and in the taskit repo (if applicable)
# If any project specific changes are required, they should be made in a separate taskfiles/<module name>/Taskfile.yaml and then imported here.

version: "3"
Expand All @@ -24,12 +24,35 @@ vars:

tasks:
default:
desc: Initializes the Taskfile setup for this project by downloading the remote taskit Taskfile Kit.
desc: Initializes taskit
summary: |
This sets up taskit for this project by cloning the taskit project to .taskit/.
It also adds the taskit gitignore entries to the project's .gitignore file.
You can find more information at https://github.com/masterpointio/taskit
To set the branch that is cloned, set the `TASKIT_BRANCH`.
To work on taskit modules locally, set the `TASKIT_LOCAL_PATH` to the path of the local taskit repo.
This sets taskit to copy the files from the local repo instead of cloning the remote repo, whichs allows you to work on taskit locally.
deps: [clean]
silent: true
aliases: [init]
cmds:
- printf "🚀 Initializing taskit...\n\n"
- |
if [[ -f .gitignore ]]; then
echo "Adding taskit gitignore entries to existing .gitignore..."
else
echo "Creating .gitignore..."
touch .gitignore
fi
if ! grep -q ".taskit" .gitignore; then
echo -e "\n## Taskit files\n.taskit/\n.task/\n.snaplet/snapshots/" >> .gitignore
fi
- |
echo -e "\n"
if [[ -z "{{.TASKIT_LOCAL_PATH}}" ]]; then
echo "Copying taskit from local path..."
rsync -rq --exclude=.git --exclude= {{.TASKIT_LOCAL_PATH}} .taskit
Expand All @@ -38,12 +61,11 @@ tasks:
git clone -b {{.TASKIT_BRANCH}} [email protected]:masterpointio/taskit.git .taskit
fi
echo -e "\n\n⚡ Taskit successfully initialized! ⚡\n"
clean:
desc: Cleans up the project's Task setup
silent: true
cmds:
- |
if [ -d .taskit ]; then
rm -rf .taskit/
fi
mkdir -p .taskit
- rm -rf .taskit/
- mkdir -p .taskit
3 changes: 1 addition & 2 deletions lib/aws/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3"
tasks:
validate-access:
desc: Validate access to AWS for the given command
# silent: true
silent: true
internal: true
set: [e]
vars:
Expand All @@ -14,7 +14,6 @@ tasks:
- MESSAGE
cmds:
- |
# Check the exit status of the command
if aws {{.AWS_COMMAND}} >/dev/null 2>&1; then
# This means the command succeeded, so do nothing, all is good.
Expand Down
14 changes: 9 additions & 5 deletions lib/snaplet/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ version: "3"
includes:
aws:
taskfile: ../aws/Taskfile.yaml
aliases: [aws]
internal: true

vars:
Expand All @@ -30,7 +29,8 @@ tasks:
list:
desc: List all available snapshots in the given S3 Bucket
silent: true
deps: [validate-snaplet-bucket-access]
deps:
- validate-snaplet-bucket-access
requires:
vars:
- SNAPLET_BUCKET
Expand All @@ -51,7 +51,8 @@ tasks:
capture:
desc: Helper for running snaplet snapshot capture.
silent: true
deps: [clean]
deps:
- clean
requires:
vars:
- SNAPLET_SOURCE_DATABASE_URL
Expand All @@ -62,7 +63,8 @@ tasks:

upload:
desc: Helper for uploading a snaplet snapshot to a given S3 Bucket
deps: [validate-snaplet-bucket-access]
deps:
- validate-snaplet-bucket-access
vars:
UPLOAD_AS_LATEST: true
requires:
Expand All @@ -80,7 +82,9 @@ tasks:
download:
desc: Downloads a snaplet snapshot from a given S3 Bucket. Pass in SNAPSHOT_NAME to download a specific snapshot from the bucket.
silent: true
deps: [clean, validate-snaplet-bucket-access]
deps:
- clean
- validate-snaplet-bucket-access
vars:
SNAPSHOT_NAME: latest
SNAPSHOT_PATH: ".snaplet/snapshots/{{.SNAPSHOT_NAME}}"
Expand Down

0 comments on commit b92b39e

Please sign in to comment.