-
Notifications
You must be signed in to change notification settings - Fork 82
Migrate to Devcontainers POC #371
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
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
8d1319f
Initial Devcontainers config
anataliocs fb4c43f
Update config
anataliocs e68310c
Update startup scripts
anataliocs c021c4f
Update devcontainer for stellar cli
anataliocs f0ace8e
Add cargo watch binaryen and make all entrypoint
anataliocs 83ddaac
Fix script perms
anataliocs 71ce798
Fix script perms
anataliocs 2e199ef
Use homebrew safely
anataliocs 4f8ef2f
Fix scripts
anataliocs 06a820b
improve caching
anataliocs 339e6ce
improve caching
anataliocs f1181ca
Update docs, cleanup and caching
anataliocs 9f037fe
code cleanup
anataliocs c540440
Clean up script to make sure stuff gets added to /Users/chris.anatali…
anataliocs 6bfd9e5
Clean up script to make sure stuff gets added to /Users/chris.anatali…
anataliocs 7445f71
Fix scripts
anataliocs bcd7007
Run checks and static analysis on bash scripts to fix
anataliocs bd50bfe
Run checks and static analysis on bash scripts to fix
anataliocs 903da9a
Create validate-devcontainer-json
anataliocs b0b0e6a
Add GH action to validate devcontainer json vs schema
anataliocs 2524666
Add GH action to validate scripts, test build and push prebuild cache
anataliocs 6eef356
Update validate-devcontainer-json.yml
anataliocs 42a606f
Fix GH action
anataliocs cb20752
Update tests.md
anataliocs abd0309
Update validate-devcontainer-json.yml
anataliocs 2f49dda
JSON Schema validation on GH Action
anataliocs 1d9cc22
JSON Schema validation on GH Action
anataliocs 0c52028
Getting JSON Schema validation and script validation and build cache …
anataliocs 8b1a4f0
Add devcontainer cli to GH Action
anataliocs 1e0da9b
Add devcontainer cli to GH Action
anataliocs 664156a
Add devcontainer cli to GH Action
anataliocs add9aca
Add devcontainer cli to GH Action
anataliocs 5429261
Add devcontainer cli to GH Action
anataliocs 1fbacb8
Add devcontainer cli to GH Action
anataliocs 4dc1b4e
Add devcontainer cli to GH Action
anataliocs 42ea804
Green GH Action JSON validation and build jobs
anataliocs a64bbca
Green GH Action JSON validation and build jobs
anataliocs 6bb7ab4
Code cleanup
anataliocs 51efba9
Update welcome message and VSCode extensions
anataliocs 120b448
Update badge to use vscode web by default
anataliocs e56a6f3
Build stellar cli and sccache from gh release binary
anataliocs 6f689ad
Build stellar cli and sccache from gh release binary
anataliocs 9bd1248
Code cleanup
anataliocs 418379b
Code cleanup
anataliocs 1b04e0c
Tune down rust analyzer, spiking CPU to 100%
anataliocs be4cdc5
Update .devcontainer/Dockerfile
anataliocs 550b12d
Update build-and-test-devcontainer.yml
anataliocs 7dd2e34
Pin bats to commit hash
anataliocs 244e772
Merge branch 'migrate-to-devcontainers-poc' of github.com:anataliocs/…
anataliocs e866798
Clean-up bash scripts
anataliocs 7479e22
Cross-platform gh cli install
anataliocs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM mcr.microsoft.com/devcontainers/rust:1.0.9-1 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive \ | ||
PKG_CONFIG_PATH='/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/share/pkgconfig' \ | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \ | ||
CARGO_INCREMENTAL=0 \ | ||
SCCACHE_DIR=/home/vscode/.cache/sccache \ | ||
SCCACHE_CONF=/home/vscode/.config/sccache/config \ | ||
SCCACHE_DIRECT=true \ | ||
RUSTC_WRAPPER=sccache \ | ||
SCCACHE_CACHE_SIZE=5G \ | ||
RUST_VERSION=1.81 | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
libdbus-1-dev \ | ||
libudev-dev \ | ||
pkg-config \ | ||
openssl && apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"name": "Soroban Examples Devcontainer", | ||
"dockerFile": "Dockerfile", | ||
"context": "..", | ||
"build": { | ||
"args": { | ||
"BUILDKIT_INLINE_CACHE": "1" | ||
} | ||
}, | ||
"hostRequirements": { | ||
"cpus": 4, | ||
"memory": "16", | ||
"storage": "32" | ||
}, | ||
"forwardPorts": [ | ||
4226 | ||
], | ||
"portsAttributes": { | ||
"4226": { | ||
"label": "sccache" | ||
} | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2.5.3": { | ||
"configureZshAsDefaultShell": true | ||
}, | ||
"ghcr.io/devcontainers/features/rust:1.3.1": { | ||
"targets": "wasm32-unknown-unknown", | ||
"profile": "default", | ||
"version": "1.81" | ||
}, | ||
"ghcr.io/devcontainers-extra/features/gh-release:1.0.25": { | ||
"repo": "stellar/stellar-cli", | ||
"binaryNames": "stellar", | ||
"version": "22.6.0" | ||
}, | ||
"ghcr.io/rapidsai/devcontainers/features/sccache:25.6.1": { | ||
"repository": "mozilla/sccache", | ||
"version": "0.10.0" | ||
} | ||
}, | ||
"customizations": { | ||
"codespaces": { | ||
"openFiles": [ | ||
"README.md", | ||
"FULL_HELP_DOCS.md", | ||
"increment/src/lib.rs", | ||
"increment/src/test.rs" | ||
] | ||
}, | ||
"vscode": { | ||
"extensions": [ | ||
"rust-lang.rust-analyzer", | ||
"vadimcn.vscode-lldb", | ||
"tamasfe.even-better-toml" | ||
], | ||
"settings": { | ||
"workbench.settings.editor": "json", | ||
"workbench.settings.useSplitJSON": true, | ||
"npm.autoDetect": "off", | ||
"telemetry.feedback.enabled": false, | ||
"workbench.tips.enabled": false, | ||
"editor.codeLens": false, | ||
"editor.minimap.enabled": false, | ||
"terminal.integrated.useWslProfiles": false, | ||
"terminal.integrated.sendKeybindingsToShell": true, | ||
"terminal.integrated.allowChords": true, | ||
"rust-analyzer.check.allTargets": false, | ||
"rust-analyzer.cargo.allTargets": false, | ||
"rust-analyzer.procMacro.attributes.enable": false, | ||
"rust-analyzer.lens.enable": false, | ||
"files.readonlyInclude": { | ||
"**/.cargo/registry/src/**/*.rs": true, | ||
"**/.cargo/git/checkouts/**/*.rs": true, | ||
"**/lib/rustlib/src/rust/library/**/*.rs": true | ||
} | ||
} | ||
} | ||
}, | ||
"initializeCommand": "", | ||
"onCreateCommand": "chmod +x .devcontainer/post_start_cli_autocomplete.sh && chmod +x .devcontainer/post_attach_welcome_text.sh", | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"updateContentCommand": "", | ||
"postCreateCommand": "", | ||
"postStartCommand": ".devcontainer/post_start_cli_autocomplete.sh", | ||
"postAttachCommand": ".devcontainer/post_attach_welcome_text.sh" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
clear | ||
|
||
echo " ⚙️ Setup testnet:" | ||
echo " stellar network use testnet" | ||
echo "" | ||
echo " 🆔 Configure an Identity:" | ||
echo " stellar keys generate --global alice --network testnet --fund" | ||
echo " stellar keys address alice" | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo " stellar keys use alice" | ||
echo "" | ||
echo " 🛠️ Build a contract(Replace 'alloc' with desired project):" | ||
echo " stellar contract build --manifest-path $CODESPACE_VSCODE_FOLDER/alloc/Cargo.toml" | ||
echo "" | ||
echo " 🧪 Run tests | 🔨Build Projects" | ||
echo " ⚠️ make all in the root directory will fill up a 32GB storage instance" | ||
echo " cd [Project] e.g. cd account" | ||
echo " cargo test ⭐️ make all" | ||
echo "" | ||
echo " 📖 Stellar CLI Manual(cmd+click) 🔗 https://developers.stellar.org/docs/tools/cli/stellar-cli" | ||
echo " 👩🔬 Stellar Lab(cmd+click) 🔗 https://lab.stellar.org/" | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
# Add Stellar CLI to $PATH | ||
chmod 644 ~/.bashrc && chmod 644 ~/.zshrc | ||
|
||
test -d /usr/local/bin/ && echo "/usr/local/bin/" >> ~/.zshrc | ||
test -d /usr/local/bin/ && echo "/usr/local/bin/" >> ~/.bashrc | ||
|
||
export PATH="/usr/local/bin/":$PATH | ||
echo "export PATH='/usr/local/bin/:$PATH'" >> ~/.zshrc | ||
echo "export PATH='/usr/local/bin/:$PATH'" >> ~/.bashrc | ||
|
||
# Stellar CLI Auto-Complete | ||
chmod 644 ~/.bashrc | ||
echo "source <(stellar completion --shell bash)" >>~/.bashrc | ||
chmod 644 ~/.zshrc | ||
echo "source <(stellar completion --shell zsh)" >>~/.zshrc | ||
echo "Enabled Stellar CLI auto-completion" | ||
|
||
echo " ✅ postStartCliAutocomplete.sh executed successfully" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bats | ||
|
||
setup() { | ||
load 'test_helper.bats' | ||
_tests_helper | ||
_create_dir_file | ||
} | ||
|
||
# executed after each test | ||
teardown() { | ||
_delete_dir_file | ||
} | ||
|
||
@test "script executes successfully and configures PATH and autocompletion" { | ||
# Copy the script to the temporary directory | ||
cp "$(dirname "$BATS_TEST_FILENAME")/post_start_cli_autocomplete.sh" "${BATS_TMPDIR}/" | ||
chmod +x "${BATS_TMPDIR}/post_start_cli_autocomplete.sh" | ||
|
||
# Set HOME to BATS_TMPDIR for the test | ||
export HOME="${BATS_TMPDIR}" | ||
|
||
# Run the script and capture its output | ||
run "${BATS_TMPDIR}/post_start_cli_autocomplete.sh" | ||
|
||
# Verify /usr/local/bin/ is appended to .bashrc and .zshrc files | ||
assert_file_contains "${BATS_TMPDIR}/.bashrc" "/usr/local/bin/" | ||
assert_file_contains "${BATS_TMPDIR}/.zshrc" "/usr/local/bin/" | ||
|
||
# Verify env PATH export in .bashrc and .zshrc | ||
assert_file_contains "${BATS_TMPDIR}/.bashrc" $'export PATH=\'/usr/local/bin/' | ||
assert_file_contains "${BATS_TMPDIR}/.zshrc" $'export PATH=\'/usr/local/bin/' | ||
|
||
# Verify stellar CLI completion is included in .bashrc and .zshrc | ||
assert_file_contains "${BATS_TMPDIR}/.bashrc" "source <(stellar completion --shell bash)" | ||
assert_file_contains "${BATS_TMPDIR}/.zshrc" "source <(stellar completion --shell zsh)" | ||
|
||
# Check script execution status is successful | ||
assert_success | ||
|
||
# Check for success message on script execution | ||
assert_output --partial "✅ postStartCliAutocomplete.sh executed successfully" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
_tests_helper() { | ||
echo "BATS LIB PATH: ${BATS_LIB_PATH}" | ||
bats_load_library bats-support | ||
bats_load_library bats-assert | ||
bats_load_library bats-file | ||
} | ||
|
||
_create_dir_file() { | ||
temp_make | ||
assert_dir_exist "${BATS_TMPDIR}" | ||
echo "Temp: ${BATS_TMPDIR}" | ||
|
||
# Create empty bash and zsh config files in the temporary directory | ||
touch "${BATS_TMPDIR}/.bashrc" | ||
touch "${BATS_TMPDIR}/.zshrc" | ||
|
||
assert_file_exists "${BATS_TMPDIR}/.bashrc" | ||
assert_file_exists "${BATS_TMPDIR}/.zshrc" | ||
} | ||
|
||
_delete_dir_file() { | ||
# Remove the files created during the test | ||
rm -f "${BATS_TMPDIR}/.bashrc" "${BATS_TMPDIR}/.zshrc" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
set -e | ||
# Define devcontainer configuration directory | ||
devcontainer_dir=".devcontainer" | ||
|
||
# Define configuration file path | ||
config_file="devcontainer.json" | ||
|
||
# Build the devcontainer | ||
devcontainer build \ | ||
--workspace-folder . \ | ||
--config $devcontainer_dir/$config_file | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Basic ignores | ||
**/target/* | ||
**/build/* | ||
**/.git | ||
**/.github | ||
**/.vscode | ||
**/.DS_Store | ||
**/node_modules | ||
**/dist | ||
**/pnpm-lock.yaml | ||
|
||
# Editor specific | ||
.idea/ | ||
|
||
Dockerfile | ||
.dockerignore | ||
node_modules | ||
npm-debug.log | ||
dist | ||
.git | ||
.gitignore | ||
.github | ||
|
||
# Logs | ||
*.log | ||
|
||
# Temporary files | ||
*.tmp | ||
*.temp | ||
*.swp | ||
*.swo | ||
*.bak | ||
*.old | ||
|
||
# Editor directories and files | ||
.vscode/ | ||
*.code-workspace | ||
|
||
# OS-specific files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
.env | ||
.devpod-internal | ||
build-devcontainer.sh | ||
z-dc-build-info/* | ||
devcontainer.md | ||
assets/ | ||
.run/ | ||
.zshrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Build and Test DevContainer | ||
|
||
on: | ||
push: | ||
paths: | ||
- '.devcontainer/' | ||
pull_request: | ||
paths: | ||
- '.devcontainer/' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
shellcheck-and-test: | ||
|
||
name: Shellcheck linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup PATH | ||
run: | | ||
echo ::notice title={Setup Permissions}::{Add permissions to .devcontainers/} | ||
chmod -R +rwx .devcontainer | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
echo ::notice title={Setup Workspace}::{Add .devcontainers/ to PATH} | ||
echo "${{github.workspace}}/.devcontainer" >> "$GITHUB_PATH" | ||
echo "${{github.workspace}}/.devcontainer/tests" >> "$GITHUB_PATH" | ||
|
||
- name: Run ShellCheck | ||
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 | ||
env: | ||
SHELLCHECK_OPTS: -s bash | ||
with: | ||
format: tty | ||
severity: error | ||
additional_files: post_start_cli_autocomplete.sh | ||
scandir: "${{github.workspace}}/.devcontainer" | ||
continue-on-error: true | ||
|
||
- name: Setup Bats and bats libs | ||
id: setup-bats | ||
uses: bats-core/bats-action@42fcc8700f773c075a16a90eb11674c0318ad507 | ||
|
||
- name: Test Devcontainer scripts | ||
shell: bash | ||
env: | ||
BATS_LIB_PATH: ${{ steps.setup-bats.outputs.lib-path }} | ||
run: bats .devcontainer/post_start_cli_autocomplete_test.bats | ||
|
||
build-with-devcontainer-cli: | ||
name: Devcontainer CLI Build and Push Cache | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup PATH | ||
run: | | ||
echo ::notice title={Setup Permissions}::{Add permissions to .devcontainers/} | ||
chmod -R +rwx .devcontainer | ||
|
||
echo ::notice title={Setup Workspace}::{Add .devcontainers/ to PATH} | ||
echo "${{github.workspace}}/.devcontainer" >> "$GITHUB_PATH" | ||
echo "${{github.workspace}}/.devcontainer/tests" >> "$GITHUB_PATH" | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
- run: npm install -g @devcontainers/cli | ||
anataliocs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
working-directory: ${{ github.workspace }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
buildkitd-flags: true | ||
cache-binary: 'true' | ||
|
||
- name: Test Devcontainer CLI Build | ||
run: | | ||
echo ::notice title={Building with Devcontainer CLI}::{Building Devcontainer} | ||
|
||
chmod +x ${{github.workspace}}/.devcontainer/tests/build_devcontainer_ci.sh | ||
${{github.workspace}}/.devcontainer/tests/build_devcontainer_ci.sh | ||
|
||
echo "### Devcontainer CLI Build Successful!!! :rocket:" >> $GITHUB_STEP_SUMMARY | ||
env: | ||
BUILDKIT_INLINE_CACHE: 1 | ||
working-directory: ${{github.workspace}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.