Skip to content

Commit

Permalink
chore: enhance CI/CD and development workflows (#21)
Browse files Browse the repository at this point in the history
- Add comprehensive GitHub Actions workflows for CI, benchmarking, and custom actions
- Update devcontainer configuration with additional extensions and settings
- Introduce custom actions for parsing GNU time output, dumping runner stats, and setting up benchmarks
- Update Makefile with more targets and improved dependency management
- Add .editorconfig for consistent code formatting
- Update rust-toolchain to latest version (1.84.1)
- Improve dependency installation and environment setup scripts
  • Loading branch information
zouguangxian authored Feb 8, 2025
1 parent 29fe58e commit 8def52e
Show file tree
Hide file tree
Showing 22 changed files with 11,055 additions and 208 deletions.
20 changes: 14 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"upgradePackages": true,
"upgradePackages": false,
"username": "root"
}
},
Expand All @@ -31,21 +31,29 @@
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "rustc --version",
// "postCreateCommand": "rustc --version",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.makefile-tools",
"ms-vscode-remote.remote-containers",
"rust-lang.rust-analyzer",
"eamodio.gitlens",
"redhat.vscode-yaml"
"redhat.vscode-yaml",
"github.vscode-github-actions",
"GitHub.vscode-codeql",
"GitHub.codespaces",
"GitHub.vscode-pull-request-github",
"EditorConfig.EditorConfig"
]
}
},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}
"remoteUser": "root",

"remoteEnv": {
"GIT_EDITOR": "nano"
}
}
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8

[Makefile*]
indent_style = tab

[Dockerfile]
indent_style = tab

[Dockerfile.**]
indent_style = tab

[install-dependencies]
indent_style = space
indent_size = 2
40 changes: 40 additions & 0 deletions .github/actions/dump-runner-stats/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Dump System Information'
description: 'Dump system information about the runner'

inputs:
cpuinfo_path:
description: 'Path to CPU info file'
required: false
default: '/proc/cpuinfo'
os_release_path:
description: 'Path to OS release file'
required: false
default: '/etc/os-release'

runs:
using: "composite"
steps:
- name: Dump runner stats
shell: bash
run: |
echo "=== Runner System Information ==="
echo "CPU Information:"
echo " - Cores: $(nproc)"
echo " - Model: $(grep "model name" ${{ inputs.cpuinfo_path }} | head -n1 | cut -d: -f2 | sed 's/^[ \t]*//')"
echo " - Architecture: $(uname -m)"
echo -e "\nMemory Information:"
echo " - Total RAM: $(free -h | awk '/^Mem:/{print $2}')"
echo " - Available RAM: $(free -h | awk '/^Mem:/{print $7}')"
echo " - Swap: $(free -h | awk '/^Swap:/{print $2}')"
echo -e "\nStorage Information:"
echo " - Available space: $(df -h . | awk 'NR==2{print $4}')"
echo " - Total space: $(df -h . | awk 'NR==2{print $2}')"
echo " - Used space: $(df -h . | awk 'NR==2{print $3}')"
echo " - Use percentage: $(df -h . | awk 'NR==2{print $5}')"
echo -e "\nOperating System:"
echo " - $(cat ${{ inputs.os_release_path }} | grep PRETTY_NAME | cut -d'"' -f2)"
echo " - Kernel: $(uname -r)"
echo "==========================="
52 changes: 52 additions & 0 deletions .github/actions/parse-gnu-time/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Dependency directories
node_modules/
jspm_packages/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory used by tools like istanbul
coverage/

# nyc test coverage
.nyc_output/

# Compiled binary addons
build/Release

# Dependency files
package-lock.json
yarn.lock

# Environment variables
.env
.env.local
.env.*.local

# IDE specific files
.idea/
.vscode/
*.swp
*.swo
25 changes: 25 additions & 0 deletions .github/actions/parse-gnu-time/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# GNU Time Parser Action

A GitHub Action that parses the output of GNU's `/usr/bin/time -v` command and converts it into structured JSON data.

## Usage

Add this action to your workflow:

```yaml
- uses: ./.github/actions/parse-gnu-time
with:
content: ${{ steps.bench.outputs.time_output }}
```
## Development
### Install Dependencies
```bash
npm install
```

### Run Tests
```bash
npm test
```
31 changes: 31 additions & 0 deletions .github/actions/parse-gnu-time/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Parse GNU Time Output'
description: 'Parse and extract metrics from GNU time -v output'

inputs:
content:
description: 'The time command output content'
required: true
fields:
description: 'Array of field names to include in output'
required: false
default: '["peak_memory_gb", "user_time_seconds", "system_time_seconds"]'

outputs:
json:
description: 'Parsed metrics in JSON format'
value: ${{ steps.parse.outputs.json }}

runs:
using: "composite"
steps:
- name: Install dependencies
shell: bash
run: cd ${{ github.action_path }} && npm ci --only=production

- name: Run parser
id: parse
shell: bash
env:
INPUT_CONTENT: ${{ inputs.content }}
INPUT_FIELDS: ${{ inputs.fields }}
run: node ${{ github.action_path }}/parse.js
Loading

0 comments on commit 8def52e

Please sign in to comment.