Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): Add devbox config #2914

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM jetpackio/devbox:latest

# Installing your devbox project
WORKDIR /code
USER root:root
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
USER ${DEVBOX_USER}:${DEVBOX_USER}
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock


# Step 6: Copying local flakes directories
COPY local-flake local-flake
COPY local-flake local-flake

RUN devbox run -- echo "Installed Packages."

RUN devbox shellenv --init-hook >> ~/.profile
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Devbox Remote Container",
"build": {
"dockerfile": "./Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"jetpack-io.devbox"
]
}
},
"remoteUser": "devbox"
}
14 changes: 7 additions & 7 deletions .envrc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to test first, if the devbox-binary is available and only then do that eval. Similarly as it has been before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point: #2921

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
strict_env
if has nix
then
unset GOPATH # Required for editors to discover the go-tools in the flake.
use flake
layout ruby
fi
# Automatically sets up your devbox environment whenever you cd into this
# directory via our direnv integration:

eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details
87 changes: 87 additions & 0 deletions .github/workflows/asdf2devbox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: "ASDF to Devbox dependency version sync"
# This is only required until https://github.com/renovatebot/renovate/issues/27543 is resolved
on:
pull_request:
paths:
- ".tool-versions"
jobs:
asdf2devbox:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
# We potentially want to add at the end a commit by the author of the most recent
# commit in this branch. However github has some protection which prevents workflows
# to run in case a commit has been pushed with the default job-specific github-token.
# For this case we need to use another one here.
#
# For more information, see:
# <https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow>
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.APP_AUTOSCALER_CI_TOKEN }} # With push token that can trigger new PR jobs

- name: Configure git
id: configure_git
shell: bash
run: |
silvestre marked this conversation as resolved.
Show resolved Hide resolved
silvestre marked this conversation as resolved.
Show resolved Hide resolved
silvestre marked this conversation as resolved.
Show resolved Hide resolved
silvestre marked this conversation as resolved.
Show resolved Hide resolved
silvestre marked this conversation as resolved.
Show resolved Hide resolved
silvestre marked this conversation as resolved.
Show resolved Hide resolved
#! /usr/bin/env bash
set -eu -o pipefail

git config --global --add safe.directory "${GITHUB_WORKSPACE}"

commit_author_name="$(git log -1 --pretty=format:'%an')"
commit_author_email="$(git log -1 --pretty=format:'%ae')"
commit_subject="$(git log -1 --pretty=format:'%s')"
readonly commit_author_name commit_author_email commit_subject

git config user.name "${commit_author_name}"
git config user.email "${commit_author_email}"

echo "commit_subject=${commit_subject}" >> "$GITHUB_OUTPUT"

- name: Install devbox
uses: jetify-com/[email protected]
with:
enable-cache: 'true'

- name: asdf2devbox.py
shell: bash
run: |
silvestre marked this conversation as resolved.
Show resolved Hide resolved
silvestre marked this conversation as resolved.
Show resolved Hide resolved
#! /usr/bin/env bash
set -eu -o pipefail

# We need the subsequent standard-message to determine if the last commit
# has already cleaned up everything. In this case this workflow should not
# change anything and we exit early.
# An alternative would be to use a tag for this. But this does affect the whole
# PR instead of just the latest commit.
tidy_message='🤖🦾🛠️ scripts/asdf2devbox.py'
readonly tidy_message

commit_message='${{steps.configure_git.outputs.commit_subject}}'
readonly commit_message

if [[ "${commit_message}" == "${tidy_message}" ]]
then
echo 'This commit was by the asdf2devbox workflow! Exiting …'
exit 0
fi

devbox run scripts/asdf2devbox.py

num_changed_files="$(git status --porcelain | wc --lines)"
declare -i -r num_changed_files
if ((num_changed_files > 0))
then
echo 'Changes to some files were necessary!'
git add .
git commit --message="${tidy_message}"
git push origin "HEAD:${GITHUB_HEAD_REF}"
else
echo 'No files changed!'
fi
echo '🏁'
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ act 0.2.62
actionlint 1.6.27
bosh 7.5.6
cf 8.7.10
concourse 7.11.2
concourse 7.10.0
direnv 2.34.0
gcloud 473.0.0
ginkgo 2.17.2
Expand Down
46 changes: 46 additions & 0 deletions devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"packages": [
"path:local-flake#bosh-bootloader",
"path:local-flake#app-autoscaler-cli-plugin",
"credhub-cli@latest",
"delve@latest",
"gh@latest",
"go-tools@latest",
"gopls@latest",
"nodejs@latest",
"nodePackages.yaml-language-server@latest",
"rubocop@latest",
"rubyPackages.solargraph@latest",
"swagger-cli@latest",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"pre-commit@latest",
"[email protected]",
"[email protected]",
"[email protected]",
"which@latest",
"jq@latest",
"[email protected]",
"python@latest",
"act@latest",
"[email protected]",
"google-cloud-sdk@latest",
"ginkgo@latest",
"temurin-bin-17@latest",
"ruby@latest",
"[email protected]"
],
"shell": {
"init_hook": [
"cf install-plugin -f $(which app-autoscaler-cli-plugin)"
],
"scripts": {
"test": [
"echo \"Error: no test specified\" && exit 1"
]
}
}
}
Loading
Loading