diff --git a/.cargo/config.toml b/.cargo/config.toml index 8d52cb5..44dc819 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,12 +1,10 @@ [alias] # bins +insta = ["bin", "cargo-insta"] llvm-cov = ["bin", "cargo-llvm-cov"] nextest = ["bin", "cargo-nextest"] -insta = ["bin", "cargo-insta"] -leptos = ["bin", "cargo-leptos"] -mutants = ["bin", "cargo-mutants"] -#testing +# testing test_codegen = ["nextest", "run", "--features", "serde,query"] test_docs = ["test", "--doc", "--features", "serde,query"] coverage_codegen = ["llvm-cov", "--no-report", "--features", "serde,query"] diff --git a/.config/nextest.toml b/.config/nextest.toml index d58fbf4..a490a19 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -15,7 +15,6 @@ dir = "target/nextest" # This section defines the default nextest profile. Custom profiles are layered # on top of the default profile. [profile.default] - # "retries" defines the number of times a test should be retried. If set to a # non-zero value, tests that succeed on a subsequent attempt will be marked as # flaky. Can be overridden through the `--retries` option. @@ -95,16 +94,7 @@ leak-timeout = "100ms" # `nextest archive` automatically includes any build output required by a standard build. # However sometimes extra non-standard files are required. # To address this, "archive.include" specifies additional paths that will be included in the archive. -archive.include = [ - # Examples: - # - # { path = "application-data", relative-to = "target" }, - # { path = "data-from-some-dependency/file.txt", relative-to = "target" }, - # - # In the above example: - # * the directory and its contents at "target/application-data" will be included recursively in the archive. - # * the file "target/data-from-some-dependency/file.txt" will be included in the archive. -] +archive.include = [] [profile.default.junit] # Output a JUnit report into the given file inside 'store.dir/'. diff --git a/.github/actions/devenv/action.yml b/.github/actions/devenv/action.yml index da24204..ae3ea90 100644 --- a/.github/actions/devenv/action.yml +++ b/.github/actions/devenv/action.yml @@ -4,9 +4,11 @@ inputs: github-token: description: Provide a github token required: true + nix-cache: description: The location of the nix cache required: true + runs: using: composite steps: @@ -17,37 +19,46 @@ runs: path: ${{ inputs.nix-cache }} key: ${{ runner.os }}-nix-cache-${{ hashFiles('**/devenv.nix', '**/devenv.yaml', '**/devenv.lock') }} restore-keys: ${{ runner.os }}-nix-cache- + - name: install nix uses: cachix/install-nix-action@v27 with: github_access_token: ${{ inputs.github-token }} + - name: import nix store cache if: steps.nix-cache.outputs.cache-hit == 'true' run: nix-store --import < ${{ inputs.nix-cache }} shell: bash + - name: enable cachix uses: cachix/cachix-action@v15 with: name: devenv + - name: install devenv.sh run: | cachix use devenv nix profile install --accept-flake-config github:cachix/devenv/v1.0.8 shell: bash + - name: build developer environment run: devenv test shell: bash + - name: update path with devenv run: devenv shell setup:ci shell: bash + - name: export nix store cache if: steps.nix-cache.outputs.cache-hit != 'true' run: nix-store --export $(find /nix/store -maxdepth 1 -name '*-*')> ${{ inputs.nix-cache }} shell: bash + - name: cache rust dependencies uses: Swatinem/rust-cache@v2 with: key: ${{ runner.os }} + - name: cache cargo binaries uses: actions/cache@v4 with: @@ -55,13 +66,16 @@ runs: key: ${{ runner.os }}-cargo-bin-${{ hashFiles('rust-toolchain.toml') }}-${{ env.RUSTUP_TOOLCHAIN }} restore-keys: | ${{ runner.os }}-cargo-bin- + - name: get pnpm store directory id: pnpm-cache run: echo "store=$(pnpm store path)" >> $GITHUB_OUTPUT shell: bash + - name: install dependencies run: install:all shell: bash + - name: setup database run: db:setup shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e6c69a..9b91542 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,12 +9,15 @@ on: pull_request: branches: - main + env: EDGEDB_INSTANCE: "edgedb_codegen" EDGEDB_BRANCH: "main" + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + jobs: lint: timeout-minutes: 15 @@ -22,14 +25,17 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 + - name: setup uses: ./.github/actions/devenv with: github-token: ${{ secrets.GITHUB_TOKEN }} nix-cache: /tmp/nixcache + - name: lint run: lint:all shell: bash + test: timeout-minutes: 15 runs-on: "ubuntu-latest" @@ -41,34 +47,41 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 + - name: setup uses: ./.github/actions/devenv with: github-token: ${{ secrets.GITHUB_TOKEN }} nix-cache: /tmp/nixcache + - name: test run: test:all shell: bash + coverage: timeout-minutes: 15 runs-on: "ubuntu-latest" steps: - name: checkout repository uses: actions/checkout@v4 + - name: setup uses: ./.github/actions/devenv with: github-token: ${{ secrets.GITHUB_TOKEN }} nix-cache: /tmp/nixcache + - name: test coverage run: coverage:all shell: bash + - name: upload coverage uses: codecov/codecov-action@v3 with: files: codecov.json fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} + build: timeout-minutes: 15 runs-on: "ubuntu-latest" @@ -80,14 +93,17 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 + - name: setup uses: ./.github/actions/devenv with: github-token: ${{ secrets.GITHUB_TOKEN }} nix-cache: /tmp/nixcache + - name: build run: cargo build shell: bash + release: if: github.event_name == 'push' runs-on: ubuntu-latest @@ -99,20 +115,24 @@ jobs: with: app-id: ${{ secrets.APP_ID }} # <-- GitHub App ID secret name private-key: ${{ secrets.APP_PRIVATE_KEY }} # <-- GitHub App private key secret name + - name: setup rust uses: dtolnay/rust-toolchain@stable + - name: checkout uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ steps.generate-token.outputs.token }} + - name: release uses: MarcoIeni/release-plz-action@v0.5 id: release-plz env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} - - name: Tag released PRs + + - name: tag released prs env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} RELEASES: ${{ steps.release-plz.outputs.releases }} diff --git a/Cargo.toml b/Cargo.toml index 750cc85..2acf44c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,6 @@ edgedb_codegen_macros = { path = "./crates/edgedb_codegen_macros", version = "0. [workspace.metadata.bin] cargo-insta = { version = "1.39.0" } cargo-llvm-cov = { version = "0.6.10" } -cargo-mutants = { version = "24.7.0" } cargo-nextest = { version = "0.9.72" } [workspace.lints.rust] diff --git a/devenv.nix b/devenv.nix index 79859c4..68aa3a2 100644 --- a/devenv.nix +++ b/devenv.nix @@ -4,17 +4,14 @@ packages = [ pkgs.cargo-binstall pkgs.cargo-run-bin - pkgs.coreutils pkgs.dprint pkgs.edgedb - pkgs.nil - pkgs.nixpkgs-fmt + pkgs.nixfmt pkgs.rustup pkgs.shfmt - pkgs.taplo - pkgs.yamlfmt ] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk; [ pkgs.libiconv + pkgs.coreutils frameworks.Security frameworks.System ]); @@ -117,22 +114,4 @@ echo "DEVENV_ROOT=$DEVENV_ROOT" >> $GITHUB_ENV echo "DEVENV_STATE=$DEVENV_STATE" >> $GITHUB_ENV ''; - scripts."setup:docker".exec = '' - set -e - # update path - echo "export PATH=$DEVENV_PROFILE/bin:\$PATH" >> /etc/profile - - echo "export DEVENV_PROFILE=$DEVENV_PROFILE" >> /etc/profile - echo "export PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> /etc/profile - echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> /etc/profile - echo "export LIBRARY_PATH=$LIBRARY_PATH" >> /etc/profile - echo "export C_INCLUDE_PATH=$C_INCLUDE_PATH" >> /etc/profile - echo "export XDG_DATA_DIRS=$XDG_DATA_DIRS" >> /etc/profile - echo "export XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS" >> /etc/profile - - echo "export DEVENV_DOTFILE=$DEVENV_DOTFILE" >> /etc/profile - echo "export DEVENV_PROFILE=$DEVENV_PROFILE" >> /etc/profile - echo "export DEVENV_ROOT=$DEVENV_ROOT" >> /etc/profile - echo "export DEVENV_STATE=$DEVENV_STATE" >> /etc/profile - ''; } diff --git a/dprint.json b/dprint.json index f338e8a..ee23133 100644 --- a/dprint.json +++ b/dprint.json @@ -1,6 +1,7 @@ { "useTabs": true, "indentWidth": 2, + "lineWidth": 100, "exec": { "commands": [ { @@ -8,24 +9,12 @@ "exts": ["rs"] }, { - "command": "shfmt --filename {{file_path}} -i 0", - "exts": [ - "sh", - "bash" - ] - }, - { - "command": "yamlfmt -in -formatter indent={{indent_width}},max_line_length={{line_width}}", - "exts": [ - "yml", - "yaml" - ] + "command": "nixfmt", + "exts": ["nix"] }, { - "command": "taplo fmt --stdin-filepath={{file_path}} -", - "exts": [ - "toml" - ] + "command": "shfmt --filename {{file_path}} -i 0", + "exts": ["sh", "bash"] } ] }, @@ -34,12 +23,18 @@ "deno": true, "useTabs": true }, + "yaml": {}, + "toml": { + "useTabs": true, + "indentWidth": 2, + "cargo.applyConventions": true + }, "markdown": { "deno": true, "textWrap": "never" }, "includes": [ - "**/*.{json,jsonc,md,toml,rs,yml,yaml,sh,bash}" + "**/*.{json,jsonc,md,toml,rs,yml,yaml,sh,bash,nix}" ], "excludes": [ "crates/edgedb_codegen/tests/compile", @@ -57,6 +52,8 @@ "plugins": [ "https://plugins.dprint.dev/json-0.19.3.wasm", "https://plugins.dprint.dev/markdown-0.17.8.wasm", - "https://plugins.dprint.dev/exec-0.5.0.json@8d9972eee71fa1590e04873540421f3eda7674d0f1aae3d7c788615e7b7413d0" + "https://plugins.dprint.dev/exec-0.5.0.json@8d9972eee71fa1590e04873540421f3eda7674d0f1aae3d7c788615e7b7413d0", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm", + "https://plugins.dprint.dev/toml-0.6.2.wasm" ] } diff --git a/setup/editors/helix/config.toml b/setup/editors/helix/config.toml deleted file mode 100644 index 8b13789..0000000 --- a/setup/editors/helix/config.toml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/setup/editors/helix/languages.toml b/setup/editors/helix/languages.toml index ef6110c..04ed78f 100644 --- a/setup/editors/helix/languages.toml +++ b/setup/editors/helix/languages.toml @@ -1,15 +1,9 @@ -[language-server.cargotomllsp] -command = "cargotomllsp" - [language-server.nil] command = "nil" [language-server.nil.config] formatting = { command = "nixpkgs-fmt" } -[language-server.tailwindcss-ls] -config = { userLanguages = { rust = "html", "*.rs" = "html" } } - [language-server.rust-analyzer.config.check] command = "clippy" features = "all" @@ -25,7 +19,7 @@ auto-format = true [[language]] name = "rust" -language-servers = ["rust-analyzer", "tailwindcss-ls"] +language-servers = ["rust-analyzer"] indent = { tab-width = 2, unit = "\t" } formatter = { command = "dprint", args = ["fmt", "--stdin", "file.rs"] } auto-format = true @@ -40,35 +34,7 @@ auto-format = true name = "toml" indent = { tab-width = 2, unit = "\t" } language-servers = ["taplo"] -formatter = { command = "dprint", args = ["fmt", "--stdin", "file.toml"] } -auto-format = true - -# [[language]] -# name = "cargotoml" -# scope = "source.toml" -# auto-format = true -# injection-regex = "toml" -# comment-token = "#" -# file-types = [{ glob = "Cargo.toml" }] -# formatter = { command = "dprint", args = ["fmt", "--stdin", "Cargo.toml"] } -# language-servers = ["taplo", "cargotomllsp"] - -# [[grammar]] -# name = "cargotoml" -# source = { git = "https://github.com/ikatyang/tree-sitter-toml", rev = "7cff70bbcbbc62001b465603ca1ea88edd668704" } - -[[language]] -name = "html" -language-servers = ["tailwindcss-ls", "vscode-html-language-server"] -indent = { tab-width = 2, unit = "\t" } -formatter = { command = "dprint", args = ["fmt", "--stdin", "file.html"] } -auto-format = true - -[[language]] -name = "css" -language-servers = ["tailwindcss-ls", "vscode-css-language-server"] -indent = { tab-width = 2, unit = "\t" } -formatter = { command = "dprint", args = ["fmt", "--stdin", "file.css"] } +formatter = { command = "dprint", args = ["fmt", "--stdin", "Cargo.toml"] } auto-format = true [[language]] @@ -77,61 +43,3 @@ language-servers = ["nil"] indent = { tab-width = 2, unit = "\t" } formatter = { command = "dprint", args = ["fmt", "--stdin", "file.nix"] } auto-format = true - -[language-server.eslint] -args = ["--stdio"] -command = "vscode-eslint-language-server" - -# Taken from https://github.com/Microsoft/vscode-eslint#settings-options -[language-server.eslint.config] -format = true -quiet = false -rulesCustomizations = [] -run = "onType" -validate = "on" -nodePath = "" -onIgnoredFiles = "off" -packageManager = "pnpm" - -[language-server.eslint.config.experimental] -useFlatConfig = true - -[language-server.eslint.config.codeAction.disableRuleComment] -enable = true -location = "separateLine" - -[language-server.eslint.config.codeAction.showDocumentation] -enable = true - -[language-server.eslint.config.codeActionsOnSave] -mode = "all" - -[language-server.eslint.config.problems] -shortenToSingleLine = false - -[language-server.typescript-language-server.config] -documentFormatting = false - -[[language]] -name = "typescript" -language-servers = [{ except-features = ["format"], name = "typescript-language-server" }, "eslint"] -roots = ["pnpm-lock.yaml", "tsconfig.json"] -indent = { tab-width = 2, unit = "\t" } -formatter = { command = "dprint", args = ["fmt", "--stdin", "file.ts"] } -auto-format = true - -[[language]] -name = "javascript" -language-servers = [{ except-features = ["format"], name = "typescript-language-server" }, "eslint"] -roots = ["pnpm-lock.yaml", "tsconfig.json", "package.json", "jsconfig.json"] -indent = { tab-width = 2, unit = "\t" } -formatter = { command = "dprint", args = ["fmt", "--stdin", "file.js"] } -auto-format = true - -[[language]] -name = "tsx" -language-servers = [{ except-features = ["format"], name = "typescript-language-server" }, "eslint"] -roots = ["pnpm-lock.yaml", "tsconfig.json"] -indent = { tab-width = 2, unit = "\t" } -formatter = { command = "dprint", args = ["fmt", "--stdin", "file.tsx"] } -auto-format = true diff --git a/setup/editors/vscode/settings.json b/setup/editors/vscode/settings.json index c8df671..21bbb57 100644 --- a/setup/editors/vscode/settings.json +++ b/setup/editors/vscode/settings.json @@ -3,29 +3,8 @@ "editor.insertSpaces": false, "editor.tabSize": 2, "dprint.path": ".devenv/profile/bin/dprint", - "tailwindCSS.includeLanguages": { - "rust": "html" - }, - "tailwindCSS.experimental.classRegex": [ - ["#[tw\\\\([^\\]]*class\\s*=\\s*\"([^\"]*)\"\\)]", "\"([^\"]*)\""] - ], - "emmet.includeLanguages": { - "rust": "html" - }, "rust-analyzer.cargo.features": "all", "rust-analyzer.check.command": "clippy", - "[css]": { - "editor.defaultFormatter": "dprint.dprint" - }, - "[dockerfile]": { - "editor.defaultFormatter": "dprint.dprint" - }, - "[javascript]": { - "editor.defaultFormatter": "dprint.dprint" - }, - "[javascriptreact]": { - "editor.defaultFormatter": "dprint.dprint" - }, "[json]": { "editor.defaultFormatter": "dprint.dprint" }, @@ -41,20 +20,10 @@ "[rust]": { "editor.defaultFormatter": "dprint.dprint" }, - "[sql]": { - "editor.defaultFormatter": "dprint.dprint" - }, "[toml]": { "editor.defaultFormatter": "dprint.dprint" }, - "[typescript]": { - "editor.defaultFormatter": "dprint.dprint" - }, - "[typescriptreact]": { - "editor.defaultFormatter": "dprint.dprint" - }, "[yaml]": { "editor.defaultFormatter": "dprint.dprint" - }, - "rust-analyzer.showUnlinkedFileNotification": false + } } diff --git a/taplo.toml b/taplo.toml deleted file mode 100644 index 656b5fb..0000000 --- a/taplo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[formatting] -indent_string = "\t" -column_width = 100 -allowed_blank_lines = 1 - -[[rule]] -include = ["**/Cargo.toml", "Cargo.toml"] -keys = ["dependencies", "dev-dependencies", "workspace.dependencies", "workspace.metadata.bin"] - -[rule.formatting] -reorder_keys = true