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

✨ add a nu-check verification CI #771

Merged
merged 30 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b1cd54a
:construction_worker: add github CI
AucaCoyan Mar 3, 2024
ce3146c
:bug: fix weird bug of actions/checkout@v4 not working
AucaCoyan Mar 3, 2024
c2b039a
:bug: it was missing a `v`
AucaCoyan Mar 3, 2024
ce5d544
:sparkles: add toolkit and lint fn
AucaCoyan Mar 3, 2024
77aeab0
:fire: remove unused action
AucaCoyan Mar 3, 2024
ecec9c4
Merge branch 'main' into add-basic-ci
AucaCoyan Mar 4, 2024
c84c802
:construction_worker: sample script with `nu-check` and `nu --ide-check`
AucaCoyan Mar 7, 2024
66e8d92
:sparkles: now `toolkit` generates a list of errors on each run
AucaCoyan Mar 8, 2024
617cb41
Merge branch 'main' into add-basic-ci
AucaCoyan Mar 9, 2024
3a16239
:fire: delete `nu-ide-and...` file
AucaCoyan Mar 9, 2024
d1e9ac2
:fire: remove unused code or comments
AucaCoyan Mar 9, 2024
3a6f371
Merge branch 'main' into add-basic-ci
AucaCoyan Mar 10, 2024
c4dda5d
Merge branch 'main' into add-basic-ci
AucaCoyan Mar 10, 2024
19e3d55
:sparkles: add failure if `toolkit check pr` fails
AucaCoyan Mar 10, 2024
5d2cf85
:truck: rename some vars
AucaCoyan Mar 10, 2024
4fe7592
:construction_worker: add features dataframe and extra to the CI
AucaCoyan Mar 11, 2024
e2d23be
:sparkles: fork analysis of all files vs git modified files
AucaCoyan Mar 11, 2024
57ebca9
:sparkles: add `full` flag to check all files
AucaCoyan Mar 11, 2024
14e9881
:sparkles: add "file is ok" line and ending OK line
AucaCoyan Mar 11, 2024
56a6121
:bug: change git diff algorithm
AucaCoyan Mar 11, 2024
0fa7432
Merge branch 'main' into add-basic-ci
AucaCoyan Mar 12, 2024
d20ee20
:bug: change `--name-status` for `name-only`
AucaCoyan Mar 12, 2024
8eba605
:bug: try with files = ""
AucaCoyan Mar 12, 2024
3db99a1
:bug: fix git branch bug
AucaCoyan Mar 12, 2024
f1cfae4
:sparkles: checkout `origin/main` in addition to PR branch
AucaCoyan Mar 12, 2024
1f93670
:sparkles: filter only the `*.nu` files
AucaCoyan Mar 12, 2024
b2d3af7
:adhesive_bandage: tiny fixes
AucaCoyan Mar 12, 2024
d190699
:sparkles: reject span column
AucaCoyan Mar 12, 2024
5d5b81d
:bug: you don't know if you will get the spam column
AucaCoyan Mar 12, 2024
a037b6f
:adhesive_bandage: remove an usused print of git branch
AucaCoyan Mar 12, 2024
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
pull_request:

env:
NUSHELL_CARGO_PROFILE: ci
NU_LOG_LEVEL: DEBUG

jobs:
nu-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: 'Fetch main branch'
run: |
git fetch origin main --depth 1
- uses: hustcer/[email protected]
with:
version: '*'
check-latest: true
features: full # dataframe and extra included
- name: toolkit check pr
shell: nu {0}
run: |
nu -c "use toolkit.nu *; check pr"
- name: run nu-check on modified files
shell: nu {0}
run: |
nu ./check-files.nu
33 changes: 33 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
branches:
- main
schedule:
- cron: '30 0 * * *' # every day at 00:30 AM UTC

env:
NUSHELL_CARGO_PROFILE: ci
NU_LOG_LEVEL: DEBUG

jobs:
nu-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: 'Fetch main branch'
run: |
git fetch origin main --depth 1
- uses: hustcer/[email protected]
with:
version: '*'
check-latest: true
features: full # dataframe and extra included
- name: toolkit generate-file-list --full
shell: nu {0}
run: |
nu -c "use toolkit.nu *; generate-file-list --full"
- name: run nu-check on all files
shell: nu {0}
run: |
nu ./check-files.nu
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

# ignore the git mailmap file
.mailmap

check-files.nu
64 changes: 64 additions & 0 deletions toolkit.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# this module regroups a bunch of development tools to make the development
# process easier for anyone.
#
# the main purpose of `toolkit` is to offer an easy to use interface for the
# developer during a PR cycle.


# check that all the tests pass
export def test [
] {
print "toolkit test: not implemented!"
}

# run all the necessary checks and tests to submit a perfect PR
export def "check pr" [
] {
generate-file-list
test
}

export def main [] { help toolkit }

export def generate-file-list [ --full ] {
let start = "let files = ["

mut files = [""]

if $full {
# all the *.nu files in the repo
# exept for `before_v0.60`
print "checking all files..."
mut $files = glob **/*.nu --exclude [before_v0.60/**]
} else {
# only the *.nu files changed in comparison with origin/main
$files = (git diff --name-only origin/main | lines | filter { str ends-with '.nu'} | each { path expand })
}


let new_list = $files | str join ",\n" | append "]"

let final = "

mut exit_code = 0
for file in $files {
let diagnostics_table = nu --ide-check 10 $file | to text | ['[', $in, ']'] | str join | from json
let result = $diagnostics_table | where type == \"diagnostic\" | is-empty
if $result {
print $\"✔ ($file) is ok\"
} else {
print $\"❌ ($file) has errors:\"
print ($diagnostics_table | where type == \"diagnostic\" | reject span)
$exit_code = 1
}
}
print $\"💚 All files checked!\"

exit $exit_code
"

$start
| append $new_list
| append $final
| save "check-files.nu" --force
}