- 
                Notifications
    You must be signed in to change notification settings 
- Fork 645
add initial cargo ci #3409
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
          
     Open
      
      
            Kasama
  wants to merge
  8
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
add/cargo-ci
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    add initial cargo ci #3409
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4824f5f
              
                add initial cargo ci
              
              
                Kasama c8581e2
              
                merge master into add/cargo-ci
              
              
                Kasama 1c0406d
              
                update cargo ci
              
              
                Kasama c5ea361
              
                [add/cargo-ci]: Merge remote-tracking branch 'origin/master' into add…
              
              
                bfops b86cce7
              
                Merge branch 'master' of github.com:clockworklabs/SpacetimeDB into ad…
              
              
                Kasama 852c13c
              
                fix: PR comments
              
              
                Kasama 2b2250a
              
                update ci to call cargo for unreal test
              
              
                Kasama a9b46b2
              
                update cargo ci docs
              
              
                Kasama File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -25,9 +25,11 @@ | |
| strategy: | ||
| matrix: | ||
| include: | ||
| - { runner: spacetimedb-runner, smoketest_args: --docker } | ||
| - { runner: windows-latest, smoketest_args: --no-build-cli } | ||
| runner: [ spacetimedb-runner, windows-latest ] | ||
| - runner: spacetimedb-runner | ||
| smoketest_args: '--docker -x clear_database replication' | ||
| - runner: windows-latest | ||
| smoketest_args: '--no-build-cli -x clear_database replication' | ||
| runner: [spacetimedb-runner, windows-latest] | ||
| runs-on: ${{ matrix.runner }} | ||
| steps: | ||
| - name: Find Git ref | ||
|  | @@ -76,8 +78,8 @@ | |
| - name: Install python deps | ||
| run: python -m pip install psycopg2-binary xmltodict | ||
| - name: Run smoketests | ||
| # Note: clear_database and replication only work in private | ||
| run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication | ||
| run: cargo ci smoketests -- ${{ matrix.smoketest_args }} | ||
|  | ||
| - name: Stop containers (Linux) | ||
| if: always() && runner.os == 'Linux' | ||
| run: docker compose down | ||
|  | @@ -118,30 +120,13 @@ | |
| with: | ||
| run_install: true | ||
|  | ||
| - name: Create /stdb dir | ||
| run: | | ||
| sudo mkdir /stdb | ||
| sudo chmod 777 /stdb | ||
|  | ||
| - name: Build typescript module sdk | ||
| working-directory: crates/bindings-typescript | ||
| run: pnpm build | ||
|  | ||
| - name: Run cargo test | ||
| #Note: Unreal tests will be run separately | ||
| run: cargo test --all -- --skip unreal | ||
|  | ||
| - name: Check that the test outputs are up-to-date | ||
| run: bash tools/check-diff.sh | ||
|  | ||
| - name: Ensure C# autogen bindings are up-to-date | ||
| run: | | ||
| cargo run -p spacetimedb-codegen --example regen-csharp-moduledef | ||
| bash tools/check-diff.sh crates/bindings-csharp | ||
|  | ||
| - name: C# bindings tests | ||
| working-directory: crates/bindings-csharp | ||
| run: dotnet test -warnaserror | ||
| run: cargo ci test | ||
|  | ||
| lints: | ||
| name: Lints | ||
|  | @@ -157,30 +142,8 @@ | |
| with: | ||
| global-json-file: global.json | ||
|  | ||
| - name: Run cargo fmt | ||
| run: cargo fmt --all -- --check | ||
|  | ||
| - name: Run cargo clippy | ||
| run: cargo clippy --all --tests --benches -- -D warnings | ||
|  | ||
| - name: Run C# formatting check | ||
| working-directory: crates/bindings-csharp | ||
| run: | | ||
| dotnet tool restore | ||
| dotnet csharpier --check . | ||
|  | ||
| - name: Run `cargo doc` for bindings crate | ||
| # `bindings` is the only crate we care strongly about documenting, | ||
| # since we link to its docs.rs from our website. | ||
| # We won't pass `--no-deps`, though, | ||
| # since we want everything reachable through it to also work. | ||
| # This includes `sats` and `lib`. | ||
| working-directory: crates/bindings | ||
| env: | ||
| # Make `cargo doc` exit with error on warnings, most notably broken links | ||
| RUSTDOCFLAGS: '--deny warnings' | ||
| run: | | ||
| cargo doc | ||
| - name: Run ci lint | ||
| run: cargo ci lint | ||
|  | ||
| wasm_bindings: | ||
| name: Build and test wasm bindings | ||
|  | @@ -192,20 +155,7 @@ | |
| - run: echo ::add-matcher::.github/workflows/rust_matcher.json | ||
|  | ||
| - name: Run bindgen tests | ||
| run: cargo test -p spacetimedb-codegen | ||
|  | ||
| # Make sure the `Cargo.lock` file reflects the latest available versions. | ||
| # This is what users would end up with on a fresh module, so we want to | ||
| # catch any compile errors arising from a different transitive closure | ||
| # of dependencies than what is in the workspace lock file. | ||
| # | ||
| # For context see also: https://github.com/clockworklabs/SpacetimeDB/pull/2714 | ||
| - name: Update dependencies | ||
| run: cargo update | ||
|  | ||
| - name: Build module-test | ||
| run: cargo run -p spacetimedb-cli -- build --project-path modules/module-test | ||
|  | ||
| run: cargo ci wasm-bindings | ||
|  | ||
| publish_checks: | ||
| name: Check that packages are publishable | ||
|  | @@ -258,19 +208,9 @@ | |
| run: sudo apt install -y libssl-dev | ||
|  | ||
| - name: Build spacetimedb-update | ||
| run: cargo build --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update | ||
|  | ||
| - name: Run self-install | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| shell: bash | ||
| run: | | ||
| ROOT_DIR="$(mktemp -d)" | ||
| # NOTE(bfops): We need the `github-token-auth` feature because we otherwise tend to get ratelimited when we try to fetch `/releases/latest`. | ||
| # My best guess is that, on the GitHub runners, the "anonymous" ratelimit is shared by *all* users of that runner (I think this because it | ||
| # happens very frequently on the `macos-runner`, but we haven't seen it on any others). | ||
| cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes | ||
| "${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help | ||
| run: cargo ci update-flow --target=${{ matrix.target }} --github-token-auth | ||
|  | ||
| unreal_engine_tests: | ||
| name: Unreal Engine Tests | ||
|  | @@ -292,26 +232,26 @@ | |
| # without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle. | ||
| options: --user 0:0 | ||
| steps: | ||
| # Uncomment this before merging so that it will run properly if run manually through the GH actions flow. It was playing weird with rolled back | ||
| # commits though. | ||
| # - name: Find Git ref | ||
| # env: | ||
| # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| # shell: bash | ||
| # run: | | ||
| # PR_NUMBER="${{ github.event.inputs.pr_number || null }}" | ||
| # if test -n "${PR_NUMBER}"; then | ||
| # GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" | ||
| # else | ||
| # GIT_REF="${{ github.ref }}" | ||
| # fi | ||
| # echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" | ||
| # Uncomment this before merging so that it will run properly if run manually through the GH actions flow. It was playing weird with rolled back | ||
| # commits though. | ||
| # - name: Find Git ref | ||
| # env: | ||
| # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| # shell: bash | ||
| # run: | | ||
| # PR_NUMBER="${{ github.event.inputs.pr_number || null }}" | ||
| # if test -n "${PR_NUMBER}"; then | ||
| # GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" | ||
| # else | ||
| # GIT_REF="${{ github.ref }}" | ||
| # fi | ||
| # echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ env.GIT_REF }} | ||
| - uses: dsherret/rust-toolchain-file@v1 | ||
| - name: Run Unreal Engine tests | ||
| - name: Install unreal engine test dependencies | ||
| working-directory: sdks/unreal | ||
| env: | ||
| UE_ROOT_PATH: /home/ue4/UnrealEngine | ||
|  | @@ -320,45 +260,41 @@ | |
| apt-get update | ||
| apt-get install -y acl curl ca-certificates | ||
|         
                  bfops marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| REPO="$GITHUB_WORKSPACE" | ||
| # Let ue4 read/write the workspace & tool caches without changing ownership | ||
| for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do | ||
| [ -d "$p" ] && setfacl -R -m u:ue4:rwX -m d:u:ue4:rwX "$p" || true | ||
| done | ||
| - name: Run Unreal Engine tests | ||
| working-directory: sdks/unreal | ||
| env: | ||
| UE_ROOT_PATH: /home/ue4/UnrealEngine | ||
| run: | | ||
| cargo ci unreal-tests | ||
|  | ||
| # Rust tool caches live under the runner tool cache so they persist | ||
| export CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo" | ||
| export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup" | ||
| mkdir -p "$CARGO_HOME" "$RUSTUP_HOME" | ||
| chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME" | ||
|  | ||
| # Make sure the UE build script is executable (and parents traversable) | ||
| UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}" | ||
| chmod a+rx "$UE_DIR" "$UE_DIR/Engine" "$UE_DIR/Engine/Build" "$UE_DIR/Engine/Build/BatchFiles/Linux" || true | ||
| chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true | ||
|  | ||
| # Run the build & tests as ue4 (who owns the UE tree) | ||
| sudo -E -H -u ue4 env \ | ||
| HOME=/home/ue4 \ | ||
| XDG_CONFIG_HOME=/home/ue4/.config \ | ||
| CARGO_HOME="$CARGO_HOME" \ | ||
| RUSTUP_HOME="$RUSTUP_HOME" \ | ||
| PATH="$CARGO_HOME/bin:$PATH" \ | ||
| bash -lc ' | ||
| set -euxo pipefail | ||
| # Install rustup for ue4 if needed (uses the shared caches) | ||
| if ! command -v cargo >/dev/null 2>&1; then | ||
| curl -sSf https://sh.rustup.rs | sh -s -- -y | ||
| fi | ||
| rustup show >/dev/null | ||
| git config --global --add safe.directory "$GITHUB_WORKSPACE" || true | ||
|  | ||
| cd "$GITHUB_WORKSPACE/sdks/unreal" | ||
| cargo --version | ||
| cargo test | ||
| ' | ||
| ci_command_docs: | ||
| name: Check CI command docs | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Find Git ref | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| shell: bash | ||
| run: | | ||
| PR_NUMBER="${{ github.event.inputs.pr_number || null }}" | ||
| if test -n "${PR_NUMBER}"; then | ||
| GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" | ||
| else | ||
| GIT_REF="${{ github.ref }}" | ||
| fi | ||
| echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" | ||
|  | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ env.GIT_REF }} | ||
|  | ||
| - uses: dsherret/rust-toolchain-file@v1 | ||
|  | ||
| - name: Check for docs change | ||
| run: cargo ci self-docs --check | ||
|  | ||
| cli_docs: | ||
| Check warningCode scanning / CodeQL Workflow does not contain permissions Medium 
      Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
     | ||
| name: Check CLI docs | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we want to replace this one with a  | ||
| permissions: read-all | ||
| runs-on: ubuntu-latest | ||
|  | @@ -407,12 +343,4 @@ | |
|  | ||
| - name: Check for docs change | ||
| run: | | ||
| cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md | ||
| pnpm format | ||
| git status | ||
| if git diff --exit-code HEAD; then | ||
| echo "No docs changes detected" | ||
| else | ||
| echo "It looks like the CLI docs have changed:" | ||
| exit 1 | ||
| fi | ||
| cargo ci cli-docs | ||
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
little nit: I kinda preferred when the skipped tests were provided here, since they're going to be skipped on every platform. Not super important, but also not super important to change (although we could consider renaming
smoketests_argstoextra_smoketest_argsto be clearer).If you prefer it this way, that's fine with me.