From c248c84aa9a8c55bb6b4e09e6b6d5a377ae5afe4 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sun, 31 Dec 2023 08:51:46 -0800 Subject: [PATCH 1/5] Lock node version in local dev and CI --- .github/workflows/ci.yaml | 18 +++-- .gitignore | 146 +++++++++++++++++++++++++++++++++++++- .node-version | 1 + 3 files changed, 157 insertions(+), 8 deletions(-) create mode 100644 .node-version diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 422b2f938ed..f23c5564e90 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -133,15 +133,15 @@ jobs: uses: actions/checkout@v4.1.1 - name: Setup Node.js runtime - uses: actions/setup-node@v4.0.0 + uses: actions/setup-node@v4.0.1 with: - node-version: 16 + node-version: "lts/*" - - name: Install npm - run: npm i -f -g npm@8.16.0 + - name: Install toolchain + run: npm ci - name: Lint and check formatting with clang-format - run: npx github:artichoke/clang-format --check include + run: npm run fmt:c -- --check text: name: Lint and format text @@ -150,6 +150,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4.1.1 + - name: Setup Node.js runtime + uses: actions/setup-node@v4.0.1 + with: + node-version: "lts/*" + + - name: Install toolchain + run: npm ci + - name: Format with prettier run: npx prettier --check '**/*' diff --git a/.gitignore b/.gitignore index dd6ff62b371..05efaed9975 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,145 @@ -# Created by https://www.toptal.com/developers/gitignore/api/vim,rust,ruby -# Edit at https://www.toptal.com/developers/gitignore?templates=vim,rust,ruby +# Created by https://www.toptal.com/developers/gitignore/api/vim,ruby,rust,node +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,ruby,rust,node + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit ### Ruby ### *.gem @@ -95,7 +235,7 @@ tags # Persistent undo [._]*.un~ -# End of https://www.toptal.com/developers/gitignore/api/vim,rust,ruby +# End of https://www.toptal.com/developers/gitignore/api/vim,ruby,rust,node # Overrides diff --git a/.node-version b/.node-version new file mode 100644 index 00000000000..b009dfb9d9f --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +lts/* From 9511eae5e8c21a42d5d9b7e44208f79b1b56dc62 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sun, 31 Dec 2023 08:52:10 -0800 Subject: [PATCH 2/5] Add package.json and lock deps --- package-lock.json | 103 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 23 +++++++++++ 2 files changed, 126 insertions(+) create mode 100644 package-lock.json create mode 100644 package.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000000..198f6a5af5d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,103 @@ +{ + "name": "@artichokeruby/strudel", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@artichokeruby/strudel", + "version": "0.0.0", + "devDependencies": { + "@artichokeruby/clang-format": "github:artichoke/clang-format#semver:^0.16.0", + "prettier": "^3.1.1" + } + }, + "node_modules/@artichokeruby/clang-format": { + "version": "0.16.0", + "resolved": "git+ssh://git@github.com/artichoke/clang-format.git#12b4ab1b97687d8c25bc8c1156245346853a2f7e", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^11.1.0", + "ignore": "^5.3.0", + "p-limit": "^5.0.0" + }, + "bin": { + "clang-format": "bin/clang-format.js" + } + }, + "node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/p-limit": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz", + "integrity": "sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000000..065a45ebdb9 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "@artichokeruby/strudel", + "version": "0.0.0", + "private": true, + "description": "Rust port and drop-in replacement for the `st_hash` C hash table library", + "keywords": [ + "c", + "rust", + "hashmap" + ], + "repository": "github:artichoke/strudel", + "author": "Ryan Lopopolo (https://hyperbo.la/)", + "homepage": "https://www.artichokeruby.org", + "bugs": "https://github.com/artichoke/strudel/issues", + "devDependencies": { + "@artichokeruby/clang-format": "github:artichoke/clang-format#semver:^0.16.0", + "prettier": "^3.1.1" + }, + "scripts": { + "fmt": "prettier --write \"**/*\"", + "fmt:c": "clang-format" + } +} From f3fb449851ca3c5667501fbabc7520fc5f352c69 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sun, 31 Dec 2023 08:52:47 -0800 Subject: [PATCH 3/5] Update npm deps with dependabot --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fa65dc85ad0..83d21d5790f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -37,3 +37,15 @@ updates: - lopopolo labels: - A-deps + - package-ecosystem: npm + directory: "/" + schedule: + interval: monthly + groups: + npm-deps: + patterns: + - "*" + assignees: + - lopopolo + labels: + - A-deps From 34694a5191688408c003cb062b47ce9182f633d2 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sun, 31 Dec 2023 08:53:02 -0800 Subject: [PATCH 4/5] Add clang-format config --- .clang-format | 12 ++++++++++++ .clang-format-ignore | 6 ++++++ 2 files changed, 18 insertions(+) create mode 100644 .clang-format create mode 100644 .clang-format-ignore diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..87bb621e70c --- /dev/null +++ b/.clang-format @@ -0,0 +1,12 @@ +--- +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +--- +Language: Cpp +PointerAlignment: Right +AlwaysBreakAfterReturnType: TopLevelDefinitions +BreakBeforeBraces: Linux +UseTab: Never +TabWidth: 2 +SortIncludes: false diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 00000000000..1be3f5097af --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1,6 @@ +.git +build +emsdk +node_modules +target +vendor From ae2d461d13c74d32c1e594cd8cde2e7bdb2cb33a Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Sun, 31 Dec 2023 08:53:15 -0800 Subject: [PATCH 5/5] Reformat with updated clang-format config --- include/st.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/include/st.h b/include/st.h index 2276a021e7e..4907a7d390d 100644 --- a/include/st.h +++ b/include/st.h @@ -19,8 +19,7 @@ typedef unsigned long st_data_t; #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP typedef unsigned LONG_LONG st_data_t; #else -#error---->> st.c requires sizeof(void \ - *) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<---- +#error---->> st.c requires sizeof(void *) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<---- #endif #define ST_DATA_T_DEFINED @@ -49,8 +48,7 @@ typedef st_data_t st_index_t; typedef int st_compare_func(st_data_t, st_data_t); typedef st_index_t st_hash_func(st_data_t); -typedef char st_check_for_sizeof_st_index_t - [SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1]; +typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1]; #define SIZEOF_ST_INDEX_T SIZEOF_VOIDP struct st_hash_type { @@ -105,21 +103,17 @@ int st_insert(st_table *, st_data_t, st_data_t); int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t)); int st_lookup(st_table *, st_data_t, st_data_t *); int st_get_key(st_table *, st_data_t, st_data_t *); -typedef int st_update_callback_func(st_data_t *key, st_data_t *value, - st_data_t arg, int existing); +typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing); /* *key may be altered, but must equal to the old key, i.e., the * results of hash() are same and compare() returns 0, otherwise the * behavior is undefined */ -int st_update(st_table *table, st_data_t key, st_update_callback_func *func, - st_data_t arg); +int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg); int st_foreach(st_table *, int (*)(ANYARGS), st_data_t); int st_foreach_check(st_table *, int (*)(ANYARGS), st_data_t, st_data_t); st_index_t st_keys(st_table *table, st_data_t *keys, st_index_t size); -st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, - st_data_t never); +st_index_t st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never); st_index_t st_values(st_table *table, st_data_t *values, st_index_t size); -st_index_t st_values_check(st_table *table, st_data_t *values, st_index_t size, - st_data_t never); +st_index_t st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never); void st_add_direct(st_table *, st_data_t, st_data_t); void st_free_table(st_table *); void st_cleanup_safe(st_table *, st_data_t);