Skip to content

Commit 898e54d

Browse files
authored
Merge pull request #1 from EnergySystemsModellingLab/add_example_code
Add example code
2 parents f3651bd + 4640b3c commit 898e54d

27 files changed

+1524
-1
lines changed

.codespell_ignore.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
crate

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
indent_style = space
8+
indent_size = 4
9+
max_line_length = 100
10+
11+
[*.md]
12+
indent_size = 2
13+
14+
[*.yaml]
15+
indent_size = 2
16+
17+
[*.yml]
18+
indent_size = 2
19+
20+
[Makefile]
21+
indent_style = tab

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "cargo"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
- package-ecosystem: "github-actions"
13+
directory: "/"
14+
schedule:
15+
interval: "weekly"

.github/workflows/auto-merge.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Dependabot and Pre-commit auto-merge
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write # Needed if in a private repository
9+
10+
jobs:
11+
auto-merge:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'pre-commit-ci[bot]' }}
14+
steps:
15+
- name: Enable auto-merge for Dependabot PRs
16+
run: gh pr merge --auto --merge "$PR_URL"
17+
env:
18+
PR_URL: ${{github.event.pull_request.html_url}}
19+
# GitHub provides this variable in the CI env. You don't
20+
# need to add anything to the secrets vault.
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Cargo Build & Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build_and_test:
13+
name: Build and test
14+
runs-on: ${{ matrix.os }}
15+
env:
16+
# Make warnings fatal
17+
RUSTFLAGS: -D warnings
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [windows-latest, ubuntu-latest]
22+
toolchain:
23+
- stable
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Cargo Cache
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.cargo
31+
target
32+
key: ${{ matrix.os }}-cargo-${{ hashFiles('Cargo.toml') }}
33+
restore-keys: |
34+
${{ matrix.os }}-cargo-${{ hashFiles('Cargo.toml') }}
35+
${{ matrix.os }}-cargo
36+
- uses: dtolnay/rust-toolchain@master
37+
with:
38+
toolchain: ${{ matrix.toolchain }}
39+
- run: cargo build --verbose
40+
- run: cargo test --verbose

.github/workflows/check-links.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Check links in Markdown files
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
schedule:
7+
- cron: "0 0 * * 1" # midnight every Monday
8+
9+
jobs:
10+
check-links:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: gaurav-nelson/github-action-markdown-link-check@v1
15+
with:
16+
use-quiet-mode: "yes"
17+
use-verbose-mode: "yes"

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Run pre-commit hooks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: [ubuntu-latest]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: dtolnay/rust-toolchain@stable
14+
- uses: pre-commit/[email protected]
15+
- uses: pre-commit-ci/[email protected]
16+
if: always()

.markdownlint.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
MD013:
3+
# Maximum number of characters
4+
line_length: 100

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-merge-conflict
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
8+
- repo: https://github.com/igorshubovych/markdownlint-cli
9+
rev: v0.38.0
10+
hooks:
11+
- id: markdownlint-fix
12+
- repo: https://github.com/pre-commit/mirrors-prettier
13+
rev: "v3.1.0"
14+
hooks:
15+
- id: prettier
16+
types_or: [yaml, json]
17+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
18+
rev: v2.13.0
19+
hooks:
20+
- id: pretty-format-toml
21+
args: [--autofix, --indent, "4", --no-sort]
22+
- id: pretty-format-rust
23+
- repo: https://github.com/doublify/pre-commit-rust
24+
rev: v1.0
25+
hooks:
26+
- id: clippy
27+
# Warnings can be suppressed by adding "-A clippy::some_warning" to args
28+
args: [--fix, --allow-dirty, --allow-staged, --, -D, clippy::all, -A, clippy::precedence]
29+
- repo: https://github.com/codespell-project/codespell
30+
rev: v2.2.6
31+
hooks:
32+
- id: codespell
33+
args: [--ignore-words, .codespell_ignore.txt]

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"rust-lang.rust-analyzer",
4+
"vadimcn.vscode-lldb",
5+
"editorconfig.editorconfig",
6+
"esbenp.prettier-vscode",
7+
"davidanson.vscode-markdownlint"
8+
]
9+
}

.vscode/launch.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "lldb",
9+
"request": "launch",
10+
"name": "Debug executable 'highs_example_rust'",
11+
"cargo": {
12+
"args": ["build", "--bin=highs_example_rust", "--package=highs_example_rust"],
13+
"filter": {
14+
"name": "highs_example_rust",
15+
"kind": "bin"
16+
}
17+
},
18+
"args": ["${workspaceFolder}/examples/placeholder/settings.toml"],
19+
"cwd": "${workspaceFolder}"
20+
},
21+
{
22+
"type": "lldb",
23+
"request": "launch",
24+
"name": "Debug unit tests in executable 'highs_example_rust'",
25+
"cargo": {
26+
"args": [
27+
"test",
28+
"--no-run",
29+
"--bin=highs_example_rust",
30+
"--package=highs_example_rust"
31+
],
32+
"filter": {
33+
"name": "highs_example_rust",
34+
"kind": "bin"
35+
}
36+
},
37+
"args": ["${workspaceFolder}/examples/placeholder/settings.toml"],
38+
"cwd": "${workspaceFolder}"
39+
}
40+
]
41+
}

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"[rust]": {
3+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
4+
},
5+
"[json]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
},
8+
"[jsonc]": {
9+
"editor.defaultFormatter": "esbenp.prettier-vscode"
10+
},
11+
"[yaml]": {
12+
"editor.defaultFormatter": "esbenp.prettier-vscode"
13+
},
14+
"[toml]": {
15+
"editor.formatOnSave": false
16+
},
17+
"editor.formatOnSave": true,
18+
"editor.rulers": [100] // default max_width for rustfmt
19+
}

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
<https://www.contributor-covenant.org/faq>. Translations are available at
128+
<https://www.contributor-covenant.org/translations>.

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "highs-example-rust"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
csv = "1.3.0"
8+
highs = "1.6.1"
9+
polars = {version = "0.40.0", features = ["lazy", "csv"]}
10+
serde = {version = "1.0.202", features = ["derive"]}
11+
toml = "0.8.13"

0 commit comments

Comments
 (0)