Use Makefile for builds (#172)

* Add makefile

* Use makefile for builds

* Fix start_server command on Windows

* Use `&` for backgrounding

Since mingw on Windows provides a bash shell, we can just use this

* Use `cmd` as shell for Windows builds

* Use `start` for backgrounding on Windows

* No need for chmod

* Specify target for server to start up

* Sleep to let the server start up

* Update build docs
next
Sayan 3 years ago committed by GitHub
parent cdae667cb0
commit 8bed8c9c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -66,20 +66,7 @@ jobs:
if: env.BUILD == 'true'
- name: Run Tests
run: |
cargo build -p skyd
cargo run -p skyd -- --nosave --noart &
cargo test --verbose -- --test-threads=1
env:
RUST_BACKTRACE: 1
if: env.IS_MD_FILE == 'false' && runner.os != 'Windows'
- name: Run Tests (Windows)
run: |
cargo build -p skyd
START /B cargo run -p skyd -- --nosave --noart
cargo test --verbose -- --test-threads=1
run: make test
env:
RUST_BACKTRACE: 1
shell: cmd
if: env.IS_MD_FILE == 'false' && runner.os == 'Windows'
if: env.IS_MD_FILE == 'false'

@ -95,23 +95,11 @@ jobs:
if: runner.os == 'Linux' && env.IS_ACTIONS_DOC == 'true'
- name: Run Tests
run: |
cargo build --target ${{ matrix.rust }} -p skyd
cargo run -p skyd --target ${{ matrix.rust }} -- --nosave --noart &
cargo test --verbose --target ${{ matrix.rust }} -- --test-threads=1
env:
RUST_BACKTRACE: 1
if: env.IS_MD_FILE == 'false' && runner.os != 'Windows'
- name: Run Tests (Windows)
run: |
cargo build -p skyd --target ${{ matrix.rust }}
START /B cargo run -p skyd --target ${{ matrix.rust }} -- --nosave --noart
cargo test --target ${{ matrix.rust }} --verbose -- --test-threads=1
run: make test
env:
RUST_BACKTRACE: 1
shell: cmd
if: env.IS_MD_FILE == 'false' && runner.os == 'Windows'
TARGET: ${{ matrix.rust }}
if: env.IS_MD_FILE == 'false'
- name: Archive artifacts
run: |
@ -198,23 +186,11 @@ jobs:
if: runner.os == 'Linux'
- name: Run Tests
run: |
cargo build --target ${{ matrix.rust }} -p skyd
cargo run -p skyd --target ${{ matrix.rust }} -- --nosave --noart &
cargo test --verbose --target ${{ matrix.rust }} -- --test-threads=1
run: make test
env:
RUST_BACKTRACE: 1
if: env.IS_MD_FILE == 'false' && runner.os == 'Linux'
- name: Run Tests (Windows)
run: |
cargo build -p skyd --target ${{ matrix.rust }}
START /B cargo run -p skyd --target ${{ matrix.rust }} -- --nosave --noart
cargo test --target ${{ matrix.rust }} --verbose -- --test-threads=1
env:
RUST_BACKTRACE: 1
shell: cmd
if: env.IS_MD_FILE == 'false' && runner.os == 'Windows'
TARGET: ${{ matrix.rust }}
if: env.IS_MD_FILE == 'false'
- name: Archive artifacts
run: |
@ -298,13 +274,11 @@ jobs:
if: env.IS_MD_FILE == 'false'
- name: Run Tests
run: |
cargo build --target ${{ matrix.rust }} -p skyd
cargo run -p skyd --target ${{ matrix.rust }} -- --nosave --noart &
cargo test --verbose --target ${{ matrix.rust }} -- --test-threads=1
run: make test
env:
RUST_BACKTRACE: 1
if: env.IS_MD_FILE == 'false' && runner.os == 'Linux'
TARGET: ${{ matrix.rust }}
if: env.IS_MD_FILE == 'false'
- name: Archive artifacts
run: |

3
.gitignore vendored

@ -8,4 +8,5 @@ snapstore.partmap
/snapshots
/.idea
.DS_Store
.sky_history
.sky_history
.sky_pid

@ -7,52 +7,52 @@ You can see a list of contributors **[here](./CONTRIBUTORS.md)**
## Ways to contribute
* **#1**: Report bugs 🐞
* **#2**: Give us ideas 💡
* **#3**: Send patches
- **#1**: Report bugs
- **#2**: Give us ideas
- **#3**: Send patches
## Coding guidelines 👩‍💻 👨‍💻
## Coding guidelines
### Special comments
* `FIXME(@<username>)` : Use this when you have made an implementation that can be improved in the future, such as improved efficiency
* `HACK(@<username>)` : Use this when the code you are using a temporary workaround
* `TODO(@<username>)` : Use this when you have kept something incomplete
* `UNSAFE(@<username>)` : Use this to explain why the `unsafe` block used is safe
- `FIXME(@<username>)` : Use this when you have made an implementation that can be improved in the future, such as improved efficiency
- `HACK(@<username>)` : Use this when the code you are using a temporary workaround
- `TODO(@<username>)` : Use this when you have kept something incomplete
- `UNSAFE(@<username>)` : Use this to explain why the `unsafe` block used is safe
### Comment style
We prefer to use a 'mixed' commenting style: a cross between the C and C++ styles.
We prefer to use a 'mixed' commenting style: a cross between the C and C++ styles.
Generally, if a comment can be explained in one-line, then follow the C++ commenting style.
In other cases, use the C style.
### Formatting
* All Rust code should be formatted using `rustfmt`
- All Rust code should be formatted using `rustfmt`
### Parts of the project
* `ci` , `.github` : CI scripts (which, under normal circumstances, don't need to be modified)
* `cli` : Source for `skysh` which is the command-line client for Skytable
* `examples` : Example configuration files
* `libsky` : This contains functions, structs, ... used by both the `cli` and the
* `server` : Source for the main database server ``
* `sky-bench` : The source for the benchmarking tool resides here
* `sky-macros` : The source for custom compiler macros used by Skytable
- `ci` , `.github` : CI scripts (which, under normal circumstances, don't need to be modified)
- `cli` : Source for `skysh` which is the command-line client for Skytable
- `examples` : Example configuration files
- `libsky` : This contains functions, structs, ... used by both the `cli` and the
- `server` : Source for the main database server ``
- `sky-bench` : The source for the benchmarking tool resides here
- `sky-macros` : The source for custom compiler macros used by Skytable
### Jargon
Each project has its own jargon — and so do we!
* _actiondoc_ and _actions docs_ : This refers to the `actions.jsonc` file, which is used by the Skytable documentation website for automatically building documentation for the actions
- _actiondoc_ and _actions docs_ : This refers to the `actions.jsonc` file, which is used by the Skytable documentation website for automatically building documentation for the actions
### Branches
The `next` branch is the _kind of_ stable branch which contains the latest changes. However, for most purposes, you should always download sources from the tags.
The `next` branch is the _kind of_ stable branch which contains the latest changes. However, for most purposes, you should always download sources from the tags.
Pushes are made directly
to next if they don't change things significantly; for example, changes in documentation comments and general optimizations. If
however the changes are huge, then they must be created on a separate branch, a pull request opened, the CI suite run and
however the changes are huge, then they must be created on a separate branch, a pull request opened, the CI suite run and
finally merged into next.
## Steps
@ -62,15 +62,34 @@ finally merged into next.
3. Sign the CLA (if you haven't signed it already)
4. One of the maintainers will review your patch and suggest changes if required
5. Once your patch is approved, it will be merged into the respective branch
6. Done, you're now one of the [contributors](./CONTRIBUTORS.md) 🎉
6. Done, you're now one of the [contributors](./CONTRIBUTORS.md)!
## Testing locally
## Development environment setup
Skytable uses a Makefile for builds and running the test suite along with a number of tools. To set these up:
1. Install the latest Rust toolchain (stable)
2. Install a C Compiler, Make, Perl and the libssl-dev package on platforms where they are required
3. First build the database server by running: `cargo build --verbose`
4. Now start the database server in the background
5. Now run `cargo test --verbose -- --test-threads=1`.
**Note:** Make sure that run the tests in a single-threaded way, else you'll find that a lot of tests fail. This is because several of the tests use the same keys
6. That's it!
**Building**
1. For debug (unoptimized) builds:
```
make build
```
2. For release (optimized) builds:
```
make release
```
> **TIP**: You can explicitly specificy a target triple by setting a `TARGET` environment variable
**Testing**
Testing is simple: just run this:
```
make test
```
> **NOTE**: Make sure port 2003 is not used by any applications

@ -0,0 +1,76 @@
TARGET_ARG =
ifneq ($(origin TARGET),undefined)
TARGET_ARG +=--target ${TARGET}
endif
BUILD_VERBOSE = cargo build --verbose $(TARGET_ARG)
# Create empty commands
STOP_SERVER =
BUILD_COMMAND =
BUILD_SERVER_COMMAND =
TEST_COMMAND =
RELEASE_COMMAND =
START_COMMAND =
ifeq ($(OS),Windows_NT)
# export windows specifc rustflags
export RUSTFLAGS = -Ctarget-feature=+crt-static
# add command to use cmd because OpenSSL can't build on Windows bash
BUILD_COMMAND += cmd /C set RUSTFLAGS = -Ctarget-feature=+crt-static
# same thing here
BUILD_SERVER_COMMAND += cmd /C
TEST_COMMAND += cmd /C
STOP_SERVER += taskkill.exe /F /IM skyd.exe
RELEASE_COMMAND += cmd /C
START_COMMAND += cmd /C START /B
else
STOP_SERVER += pkill skyd
# make sure to set executable permissions
endif
# Assemble the commands
BUILD_SERVER_COMMAND += $(BUILD_VERBOSE)
BUILD_SERVER_COMMAND += -p skyd
RELEASE_COMMAND += cargo build --release $(TARGET_ARG)
BUILD_COMMAND += $(BUILD_VERBOSE)
TEST_COMMAND += cargo test $(TARGET_ARG) -- --test-threads=1
START_COMMAND += cargo run $(TARGET_ARG) -p skyd -- --noart --nosave
ifneq ($(OS),Windows_NT)
START_COMMAND += &
endif
build:
@echo "===================================================================="
@echo "Building all binaries in debug mode (unoptimized)"
@echo "===================================================================="
@$(BUILD_COMMAND)
build-server:
@echo "===================================================================="
@echo "Building server binary in debug mode (unoptimized)"
@echo "===================================================================="
@$(BUILD_SERVER_COMMAND)
release:
@echo "===================================================================="
@echo "Building all binaries in release mode (optimized)"
@echo "===================================================================="
cargo build --release --verbose $(TARGET_ARG)
test: build-server
@echo "===================================================================="
@echo "Starting database server in background"
@echo "===================================================================="
@${START_COMMAND}
# sleep for 5s to let the server start up
@sleep 5
@echo "===================================================================="
@echo "Running all tests"
@echo "===================================================================="
cargo test $(TARGET_ARG) -- --test-threads=1
@$(STOP_SERVER)
rm .sky_pid
clean:
@echo "===================================================================="
@echo "Cleaning up target folder"
@echo "===================================================================="
cargo clean
Loading…
Cancel
Save