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 ci #15

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
27 changes: 27 additions & 0 deletions .github/workflows/auto_dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Auto Dependabot
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release

on:
release:
types: [released]

jobs:
release-crate:
name: release crate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: "1.81.0"
- run: cargo publish --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
75 changes: 75 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Tests

on:
push:
branches:
- master
pull_request:

jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
skip_after_successful_duplicate: "true"
paths_ignore: '["**/*.md", "**/*.svg", "**/*.png", ".gitignore"]'

lint_check:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: "1.81.0"
components: clippy
override: true
- name: Checking code format
run: cargo fmt -- --check --config use_try_shorthand=true
- name: Clippy
uses: clechasseur/rs-clippy-check@v3
with:
args: --all-features --bins --examples --tests --benches -- -W clippy::all -W clippy::pedantic -D warnings

tests:
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
container:
image: docker.binary.picodata.io/picodata:24.6.1
options: --user root
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install system dependencies
run: dnf install -y gcc git
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: "1.81.0"
override: true
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
tmp
local
/local
/tests/tmp/*
!/tests/tmp/.keep
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ log = "0.4.22"
[[bin]]
name = "cargo-pike"
path = "src/main.rs"

[dev-dependencies]
constcat = "0.5.1"
41 changes: 41 additions & 0 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Maintenance guide

## Making a new release

1. Update master branch

```shell
git checkout master && git pull
```

1. Update project version in `Cargo.toml`

```shell
vim Cargo.toml
```

1. Update `Cargo.lock`

```shell
cargo update
```

1. Commit `Cargo.toml` and `Cargo.lock` with the version

```shell
git commit -m "bump version" Cargo.toml Cargo.lock
```

1. Make a new git tag

```shell
git tag -a <NEW_VERSION>
```

1. Push all to upstream

```shell
git push origin master --follow-tags
```

1. [Create](https://github.com/lowitea/gitlobster/releases/new) a new release specifying pushed tag
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ cargo pike run --topology topology.toml --data-dir ./tmp

#### Доступные опции

- `-t, --topology <TOPOLOGY>` - Путь к файлу топологии. Значение по-умолчанию: `topology.toml`
- `-d, --data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по-умолчанию: `./tmp`
- `-t, --topology <TOPOLOGY>` - Путь к файлу топологии. Значение по умолчанию: `topology.toml`
- `--data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по умолчанию: `./tmp`
- `--disable-install-plugins` - Отключение автоматической установки плагинов
- `-b, --base-http-port <BASE_HTTP_PORT>` - Базовый http-порт, с которого начнут открываться http-порты отдельных инстансов. Значение по-умолчанию: `8000`
- `-b, --base-pg-port <BASE_PG_PORT>` - Базовый порт постгрес протокола, с которого начнут открываться порты отдельных инстансов. Значение по-умолчанию: `5432`
- `--picodata-path <BINARY_PATH>` - Путь до исполняемого файла Пикодаты. Значение по-умолчанию: `picodata`
- `--base-http-port <BASE_HTTP_PORT>` - Базовый http-порт, с которого начнут открываться http-порты отдельных инстансов. Значение по умолчанию: `8000`
- `--base-pg-port <BASE_PG_PORT>` - Базовый порт постгрес протокола, с которого начнут открываться порты отдельных инстансов. Значение по умолчанию: `5432`
- `--picodata-path <BINARY_PATH>` - Путь до исполняемого файла Пикодаты. Значение по умолчанию: `picodata`
- `--release` - Сборка и запуск релизной версии плагина.

#### config.yaml
Expand Down Expand Up @@ -130,7 +130,7 @@ cargo pike stop --data-dir ./tmp

#### Доступные опции

- `-d, --data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по-умолчанию: `./tmp`
- `--data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по умолчанию: `./tmp`

### `plugin clean`

Expand All @@ -142,7 +142,7 @@ cargo pike clean

#### Доступные опции

- `-d, --data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по-умолчанию: `./tmp`
- `--data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по умолчанию: `./tmp`

### `plugin new`

Expand All @@ -157,7 +157,7 @@ cargo pike plugin new name_of_new_plugin
#### Доступные опции

- `--without-git` - Отключение автоматической инициализации git-репозитория
- `-w, --workspace` - Создание проекта плагина как воркспейса
- `--workspace` - Создание проекта плагина как воркспейса

### `plugin init`

Expand All @@ -172,7 +172,7 @@ cargo pike plugin init
#### Доступные опции

- `--without-git` - Отключение автоматической инициализации git-репозитория
- `-w, --workspace` - Создание проекта плагина как воркспейса
- `--workspace` - Создание проекта плагина как воркспейса

### `plugin pack`

Expand Down Expand Up @@ -207,5 +207,5 @@ cargo pike config apply

#### Доступные опции

- `-c, --config-path <CONFIG>` - Путь к файлу конфига. Значение по-умолчанию: `plugin_config.yaml`
- `-d, --data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по-умолчанию: `./tmp`
- `-c, --config-path <CONFIG>` - Путь к файлу конфига. Значение по умолчанию: `plugin_config.yaml`
- `--data-dir <DATA_DIR>` - Путь к директории хранения файлов кластера. Значение по умолчанию: `./tmp`
2 changes: 1 addition & 1 deletion src/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn cmd(data_dir: &Path) -> Result<()> {
.context(format!("failed to remove directory {}", data_dir.display()))?;
info!("Successfully removed : {}", data_dir.to_string_lossy());
} else {
warn!("Data directory does not exist")
warn!("Data directory does not exist");
}

Ok(())
Expand Down
8 changes: 4 additions & 4 deletions src/commands/config/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ fn apply_service_config(
plugin_name: &str,
plugin_version: &str,
service_name: &str,
config: HashMap<String, Value>,
config: &HashMap<String, Value>,
admin_socket: &Path,
) -> Result<()> {
let mut queries: Vec<String> = Vec::new();

for (key, value) in &config {
for (key, value) in config {
let value = serde_json::to_string(&value)
.context(format!("failed to serialize the string with key {key}"))?;
queries.push(format!(
Expand Down Expand Up @@ -83,12 +83,12 @@ pub fn cmd(config_path: &Path, data_dir: &Path) -> Result<()> {
&cargo_manifest.package.name,
&cargo_manifest.package.version,
&service_name,
service_config,
&service_config,
&admin_socket,
)
.context(format!(
"failed to apply service config for service {service_name}"
))?
))?;
}

Ok(())
Expand Down
1 change: 1 addition & 0 deletions src/commands/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub enum BuildType {
Debug,
}

#[allow(clippy::needless_pass_by_value)]
pub fn cargo_build(build_type: BuildType) -> Result<()> {
let output = match build_type {
BuildType::Release => Command::new("cargo")
Expand Down
8 changes: 4 additions & 4 deletions src/commands/plugin/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
ffi::OsStr,
fs::{self, File},
io::Write,
path::{Path, PathBuf},
path::Path,
process::Command,
};

Expand Down Expand Up @@ -71,14 +71,14 @@ where
Ok(())
}

fn workspace_init(root_path: &PathBuf, project_name: &str) -> Result<()> {
fn workspace_init(root_path: &Path, project_name: &str) -> Result<()> {
let cargo_toml_path = root_path.join("Cargo.toml");

let mut cargo_toml =
File::create(cargo_toml_path).context("failed to create Cargo.toml for workspace")?;

cargo_toml
.write_all(format!("[workspace]\nmembers = [\n \"{}\",\n]", project_name).as_bytes())?;
.write_all(format!("[workspace]\nmembers = [\n \"{project_name}\",\n]").as_bytes())?;

fs::copy(
root_path.join(project_name).join("topology.toml"),
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn cmd(path: Option<&Path>, without_git: bool, init_workspace: bool) -> Resu
let plugin_path = if init_workspace {
path.join(project_name)
} else {
path.to_path_buf()
path.clone()
};

std::fs::create_dir_all(&plugin_path)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/plugin/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn cmd(pack_debug: bool) -> Result<()> {
)
.context("failed to parse Cargo.toml")?;

let normalized_package_name = cargo_manifest.package.name.replace("-", "_");
let normalized_package_name = cargo_manifest.package.name.replace('-', "_");

let compressed_file = File::create(format!(
"target/{}-{}.tar.gz",
Expand All @@ -77,7 +77,7 @@ pub fn cmd(pack_debug: bool) -> Result<()> {

let lib_name = format!("lib{normalized_package_name}.{LIB_EXT}");
let mut lib_file =
File::open(build_dir.join(&lib_name)).context(format!("failed to open {}", lib_name))?;
File::open(build_dir.join(&lib_name)).context(format!("failed to open {lib_name}"))?;

let mut manifest_file =
File::open(build_dir.join("manifest.yaml")).context("failed to open file manifest.yaml")?;
Expand Down
Loading
Loading