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

Replace zx with execa for debug script #109

Merged
merged 2 commits into from
Oct 24, 2023
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.idea/
.vagrant/
test/ubuntu/*.log
config.yml
config.yml
debug/node_modules
8 changes: 3 additions & 5 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Upstream-Name: System Automation
Upstream-Contact: Florian Wilhelm <[email protected]>
Source: https://github.com/fwilhe2/system-automation

# Sample paragraph, commented out:
#
# Files: src/*
# Copyright: $YEAR $NAME <$CONTACT>
# License: ...
Files: debug/package*json
Copyright: 2023 Florian Wilhelm <[email protected]>
License: MIT
7 changes: 6 additions & 1 deletion debug/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ SPDX-License-Identifier: MIT -->

Local debugging setup.

See [here](https://github.com/google/zx#install) for setup of `zx`.
Uses [execa](https://github.com/sindresorhus/execa/blob/main/docs/scripts.md) for scripting.

```
npm ci
NODE_DEBUG=execa node index.js | grep 'ok='
```
8 changes: 0 additions & 8 deletions debug/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,3 @@
- name: Print all available facts
ansible.builtin.debug:
var: ansible_facts

# - name: Get Ubuntu codename
# set_fact:
# ubuntu_codename: "{{ 'impish' if ansible_lsb.description is search('development branch', ignorecase=True) else ansible_distribution_release }}"

# - name: dbg
# ansible.builtin.debug:
# msg: "Ubuntu codename {{ ubuntu_codename }}, {{ ansible_lsb.description }}, {{ ansible_distribution_release }}"
10 changes: 6 additions & 4 deletions debug/run.mjs → debug/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env zx

// SPDX-FileCopyrightText: Florian Wilhelm
// SPDX-License-Identifier: MIT

import { $ } from 'execa';

const matrix = {
'debian': ['latest', 'testing', 'unstable'],
'ubuntu': ['latest', 'rolling', 'devel'],
Expand All @@ -20,5 +20,7 @@ await Promise.all(pulls)
const builds = distros.flatMap(distro => matrix[distro].map(tag => $`docker build --file=Dockerfile.${distro} --build-arg=VERSION=${tag} --tag=debug-${distro}:${tag} .`))
await Promise.all(builds)

const runs = images.map(image => $`docker run -t --rm -v $PWD:/debug debug-${image}`)
await Promise.all(runs)
const runs = images.map(image => $`docker run -t --rm -v ${process.cwd()}:/debug debug-${image}`)
const processes = await Promise.all(runs)

processes.forEach(p => console.log(p.stdout))
204 changes: 204 additions & 0 deletions debug/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions debug/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "debug",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"execa": "^8.0.1"
}
}
Loading