Skip to content

Commit

Permalink
move slang infra to cargo (#565)
Browse files Browse the repository at this point in the history
- add `infra_cli` crate to contain commands to build, test, version, and
publish projects in this repository.
- move napi build pipeline to cargo, along with packaging/publishing.
- fix intellisense bug, where now cargo is blocking correctly on codegen
completion/success from output crates.
- make sure all crates reference other crates via relative paths, and
stop hard-coded full paths that often break.
- make sure codegen runs, even when there are merge conflicts in
generated files, instead of just failing. Often the conflicts are
resolved by the new output.
- update CI and devcontainer to use the new setup.
  • Loading branch information
OmarTawfik authored Aug 8, 2023
1 parent 6d75a7c commit 19b42e5
Show file tree
Hide file tree
Showing 203 changed files with 11,328 additions and 6,889 deletions.
6 changes: 1 addition & 5 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",

"access": "public",
"baseBranch": "main",
"changelog": ["@changesets/changelog-github", { "repo": "NomicFoundation/slang" }],

"_COMMENT_": "All packages should be ignored by default, except the single 'changelog' private package.",
"ignore": ["@nomicfoundation/*", "@slang-private/*"]
"changelog": ["@changesets/changelog-github", { "repo": "NomicFoundation/slang" }]
}
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"build": {
"dockerfile": "Dockerfile"
},
"postAttachCommand": "/bin/bash scripts/setup/all.sh",
"postAttachCommand": "/bin/bash scripts/bin/infra setup",
"portsAttributes": {
// Keep in-sync with the port number defined in "$REPO_ROOT/scripts/mkdocs/watch.sh":
// _MKDOCS_WATCH_PORT_ | keep in sync with the port number defined in "$REPO_ROOT/crates/infra/cli/src/toolchains/mkdocs/mod.rs"
"5353": {
"label": "mkdocs",
"onAutoForward": "openPreview"
Expand Down
53 changes: 22 additions & 31 deletions .github/workflows/_jobs_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
- name: "Clone repository"
uses: "actions/checkout@v3.4.0"

- name: "Prepare Repository"
# Mark the repository as a safe directory in git: https://github.com/actions/checkout/issues/766
run: "git config --global --add safe.directory $GITHUB_WORKSPACE"

- name: "Restore hermit cache"
if: "${{ github.ref_name != 'main' }}"
uses: "actions/cache/restore@v3.3.1"
Expand All @@ -30,7 +34,7 @@ jobs:
if: "${{ github.ref_name != 'main' }}"
uses: "actions/cache/restore@v3.3.1"
with:
path: "target/"
path: "**/target/"
key: "build-cache-${{ hashFiles('Cargo.lock', 'package-lock.json', 'Pipfile.lock') }}"
restore-keys: "build-cache-"

Expand All @@ -39,52 +43,39 @@ jobs:
with:
entrypoint: "echo"

- name: "Install Dependencies"
- name: "scripts/bin/infra setup"
id: "installDependencies"
uses: "./.devcontainer"
with:
entrypoint: "scripts/setup/all.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "setup"

#
# Checks:
# Run all checks and report issues found, even if other checks failed:
#

- name: "Cargo check"
if: "${{ (success() || failure()) && steps.installDependencies.outcome == 'success' }}"
uses: "./.devcontainer"
with:
entrypoint: "scripts/cargo/check.sh"

- name: "Cargo test"
if: "${{ (success() || failure()) && steps.installDependencies.outcome == 'success' }}"
uses: "./.devcontainer"
with:
entrypoint: "scripts/cargo/test.sh"

- name: "NPM build"
if: "${{ (success() || failure()) && steps.installDependencies.outcome == 'success' }}"
uses: "./.devcontainer"
with:
entrypoint: "scripts/npm/build.sh"

- name: "NPM test"
if: "${{ (success() || failure()) && steps.installDependencies.outcome == 'success' }}"
- name: "scripts/bin/infra check"
uses: "./.devcontainer"
with:
entrypoint: "scripts/npm/test.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "check"

- name: "Build documentation"
if: "${{ (success() || failure()) && steps.installDependencies.outcome == 'success' }}"
- name: "scripts/bin/infra test"
uses: "./.devcontainer"
with:
entrypoint: "scripts/mkdocs/build.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "test"

- name: "Run linters"
if: "${{ (success() || failure()) && steps.installDependencies.outcome == 'success' }}"
- name: "scripts/bin/infra lint"
uses: "./.devcontainer"
with:
entrypoint: "scripts/lint/all.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "lint"

#
# Update cache files:
Expand All @@ -102,5 +93,5 @@ jobs:
- name: "Save build cache"
uses: "actions/cache/save@v3.3.1"
with:
path: "target/"
path: "**/target/"
key: "build-cache-${{ hashFiles('Cargo.lock', 'package-lock.json', 'Pipfile.lock') }}"
21 changes: 15 additions & 6 deletions .github/workflows/_jobs_github_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ jobs:
#

- name: "Clone repository"
# Mark the repository as a safe directory in git: https://github.com/actions/checkout/issues/766
uses: "actions/checkout@v3.4.0"

- name: "Prepare Repository"
run: "git config --global --add safe.directory $GITHUB_WORKSPACE"

- name: "Restore hermit cache"
uses: "actions/cache/restore@v3.3.1"
with:
Expand All @@ -35,7 +39,7 @@ jobs:
- name: "Restore build cache"
uses: "actions/cache/restore@v3.3.1"
with:
path: "target/"
path: "**/target/"
key: "build-cache-${{ hashFiles('Cargo.lock', 'package-lock.json', 'Pipfile.lock') }}"
fail-on-cache-miss: true

Expand All @@ -44,27 +48,32 @@ jobs:
with:
entrypoint: "echo"

- name: "Install Dependencies"
- name: "scripts/bin/infra setup pipenv"
uses: "./.devcontainer"
with:
entrypoint: "scripts/setup/all.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "setup pipenv"

#
# Deploy to GitHub Pages:
#

- name: "Build documentation"
- name: "scripts/bin/infra check mkdocs"
uses: "./.devcontainer"
with:
entrypoint: "scripts/mkdocs/build.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "check mkdocs"
SLANG_MKDOCS_DOCUMENTATION_SITE_DIR: "documentation/target/release"

- name: "Configure GitHub Pages"
uses: "actions/configure-pages@v3.0.5"

- name: "Upload artifacts"
uses: "actions/upload-pages-artifact@v1.0.7"
with:
path: "target/documentation"
path: "documentation/target/release"

- name: "Deploy to GitHub Pages"
id: "deployment"
Expand Down
58 changes: 32 additions & 26 deletions .github/workflows/_jobs_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,27 @@ jobs:

steps:
- name: "Clone repository"
# Mark the repository as a safe directory in git: https://github.com/actions/checkout/issues/766
uses: "actions/checkout@v3.4.0"

- name: "Install Dependencies"
run: "scripts/setup/all.sh"
- name: "Prepare Repository"
run: "git config --global --add safe.directory $GITHUB_WORKSPACE"

- name: "Analyze Changesets"
- name: "scripts/bin/infra setup npm"
run: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "setup npm"

- name: "scripts/bin/infra bump-version"
id: "changesets"
uses: "changesets/action@v1.4.1"
with:
title: "Bump Slang Version"
commit: "Bump Slang Version"
createGithubReleases: false
version: "scripts/changelog/bump-version.sh"
version: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "bump-version"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

outputs:
Expand All @@ -45,8 +52,12 @@ jobs:
#

- name: "Clone repository"
# Mark the repository as a safe directory in git: https://github.com/actions/checkout/issues/766
uses: "actions/checkout@v3.4.0"

- name: "Prepare Repository"
run: "git config --global --add safe.directory $GITHUB_WORKSPACE"

- name: "Restore hermit cache"
uses: "actions/cache/restore@v3.3.1"
with:
Expand All @@ -57,7 +68,7 @@ jobs:
- name: "Restore build cache"
uses: "actions/cache/restore@v3.3.1"
with:
path: "target/"
path: "**/target/"
key: "build-cache-${{ hashFiles('Cargo.lock', 'package-lock.json', 'Pipfile.lock') }}"
fail-on-cache-miss: true

Expand All @@ -66,50 +77,45 @@ jobs:
with:
entrypoint: "echo"

- name: "Install Dependencies"
- name: "scripts/bin/infra setup cargo npm"
uses: "./.devcontainer"
with:
entrypoint: "scripts/setup/all.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_INFRA_CLI_EXTRA_ARGS: "setup cargo npm"

#
# Build and Publish:
#

- name: "Build Native Binaries"
uses: "./.devcontainer"
with:
entrypoint: "scripts/npm/build.sh"
env:
SLANG_CROSS_BUILD: "true"

- name: "Publish to NPM"
- name: "scripts/bin/infra publish npm"
uses: "./.devcontainer"
with:
entrypoint: "scripts/npm/publish.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_PUBLISH: "true"
SLANG_INFRA_CLI_EXTRA_ARGS: "publish npm"
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"

- name: "Publish to Cargo"
- name: "scripts/bin/infra publish cargo"
uses: "./.devcontainer"
with:
entrypoint: "scripts/cargo/publish.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_PUBLISH: "true"
SLANG_INFRA_CLI_EXTRA_ARGS: "publish cargo"
CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}"

- name: "Create GitHub Release"
- name: "scripts/bin/infra publish github-release"
uses: "./.devcontainer"
with:
entrypoint: "scripts/changelog/create-release.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_PUBLISH: "true"
SLANG_INFRA_CLI_EXTRA_ARGS: "publish github-release"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: "Update Lock Files"
- name: "scripts/bin/infra publish lock-files"
uses: "./.devcontainer"
with:
entrypoint: "scripts/changelog/update-lock-files.sh"
entrypoint: "scripts/bin/infra"
env:
SLANG_PUBLISH: "true"
SLANG_INFRA_CLI_EXTRA_ARGS: "publish lock-files"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Ember Templates
documentation/overrides/**/*.html

# Tera Templates
**/*.tera

# Packages and Dependencies
.hermit/
node_modules/
Expand Down
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
{
"label": "Validate Solidity Definition",
"type": "shell",
"command": "scripts/solidity/validate-definition.sh",
"command": "${workspaceFolder}/scripts/bin/infra",
"args": ["check", "cargo"],
"options": {
"env": {
"VSCODE_PROBLEM_MATCHER": "true"
}
},
"problemMatcher": {
"owner": "solidity",
"source": "codegen_utils",
"source": "slang",
"applyTo": "allDocuments",
"fileLocation": "absolute",
"pattern": [
Expand All @@ -33,7 +34,6 @@
]
},
"runOptions": {
"runOn": "folderOpen",
"instanceLimit": 1
},
"presentation": {
Expand Down
Loading

0 comments on commit 19b42e5

Please sign in to comment.