Skip to content

Commit c1ff390

Browse files
committed
Give the people what they want
0 parents  commit c1ff390

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+9235
-0
lines changed

.github/workflows/release.yml

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# CI that:
2+
#
3+
# * checks for a Git Tag that looks like a release
4+
# * creates a Github Release™ and fills in its text
5+
# * builds artifacts with cargo-dist (executable-zips, installers)
6+
# * uploads those artifacts to the Github Release™
7+
#
8+
# Note that the Github Release™ will be created before the artifacts,
9+
# so there will be a few minutes where the release has no artifacts
10+
# and then they will slowly trickle in, possibly failing. To make
11+
# this more pleasant we mark the release as a "draft" until all
12+
# artifacts have been successfully uploaded. This allows you to
13+
# choose what to do with partial successes and avoids spamming
14+
# anyone with notifications before the release is actually ready.
15+
name: Release
16+
17+
permissions:
18+
contents: write
19+
20+
# This task will run whenever you push a git tag that looks like a version
21+
# like "v1", "v1.2.0", "v0.1.0-prerelease01", "my-app-v1.0.0", etc.
22+
# The version will be roughly parsed as ({PACKAGE_NAME}-)?v{VERSION}, where
23+
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
24+
# must be a Cargo-style SemVer Version.
25+
#
26+
# If PACKAGE_NAME is specified, then we will create a Github Release™ for that
27+
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
28+
#
29+
# If PACKAGE_NAME isn't specified, then we will create a Github Release™ for all
30+
# (cargo-dist-able) packages in the workspace with that version (this is mode is
31+
# intended for workspaces with only one dist-able package, or with all dist-able
32+
# packages versioned/released in lockstep).
33+
#
34+
# If you push multiple tags at once, separate instances of this workflow will
35+
# spin up, creating an independent Github Release™ for each one.
36+
#
37+
# If there's a prerelease-style suffix to the version then the Github Release™
38+
# will be marked as a prerelease.
39+
on:
40+
push:
41+
tags:
42+
- '*-?v[0-9]+*'
43+
44+
jobs:
45+
# Create the Github Release™ so the packages have something to be uploaded to
46+
create-release:
47+
runs-on: ubuntu-latest
48+
outputs:
49+
has-releases: ${{ steps.create-release.outputs.has-releases }}
50+
env:
51+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
steps:
53+
- uses: actions/checkout@v3
54+
- name: Install Rust
55+
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
56+
- name: Install cargo-dist
57+
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.5/cargo-dist-v0.0.5-installer.sh | sh
58+
- id: create-release
59+
run: |
60+
cargo dist manifest --tag=${{ github.ref_name }} --artifacts=all --no-local-paths --output-format=json > dist-manifest.json
61+
echo "dist manifest ran successfully"
62+
cat dist-manifest.json
63+
64+
# Create the Github Release™ based on what cargo-dist thinks it should be
65+
ANNOUNCEMENT_TITLE=$(cat dist-manifest.json | jq --raw-output ".announcement_title")
66+
IS_PRERELEASE=$(cat dist-manifest.json | jq --raw-output ".announcement_is_prerelease")
67+
cat dist-manifest.json | jq --raw-output ".announcement_github_body" > new_dist_announcement.md
68+
gh release create ${{ github.ref_name }} --draft --prerelease="$IS_PRERELEASE" --title="$ANNOUNCEMENT_TITLE" --notes-file=new_dist_announcement.md
69+
echo "created announcement!"
70+
71+
# Upload the manifest to the Github Release™
72+
gh release upload ${{ github.ref_name }} dist-manifest.json
73+
echo "uploaded manifest!"
74+
75+
# Disable all the upload-artifacts tasks if we have no actual releases
76+
HAS_RELEASES=$(cat dist-manifest.json | jq --raw-output ".releases != null")
77+
echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT"
78+
79+
# Build and packages all the things
80+
upload-artifacts:
81+
# Let the initial task tell us to not run (currently very blunt)
82+
needs: create-release
83+
if: ${{ needs.create-release.outputs.has-releases == 'true' }}
84+
strategy:
85+
matrix:
86+
# For these target platforms
87+
include:
88+
- os: macos-11
89+
dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
90+
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.5/cargo-dist-v0.0.5-installer.sh | sh
91+
- os: ubuntu-20.04
92+
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
93+
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.5/cargo-dist-v0.0.5-installer.sh | sh
94+
- os: windows-2019
95+
dist-args: --artifacts=local --target=x86_64-pc-windows-msvc
96+
install-dist: irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.5/cargo-dist-v0.0.5-installer.ps1 | iex
97+
98+
runs-on: ${{ matrix.os }}
99+
env:
100+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
steps:
102+
- uses: actions/checkout@v3
103+
- name: Install Rust
104+
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
105+
- name: Install cargo-dist
106+
run: ${{ matrix.install-dist }}
107+
- name: Run cargo-dist
108+
# This logic is a bit janky because it's trying to be a polyglot between
109+
# powershell and bash since this will run on windows, macos, and linux!
110+
# The two platforms don't agree on how to talk about env vars but they
111+
# do agree on 'cat' and '$()' so we use that to marshal values between commands.
112+
run: |
113+
# Actually do builds and make zips and whatnot
114+
cargo dist build --tag=${{ github.ref_name }} --output-format=json ${{ matrix.dist-args }} > dist-manifest.json
115+
echo "dist ran successfully"
116+
cat dist-manifest.json
117+
118+
# Parse out what we just built and upload it to the Github Release™
119+
cat dist-manifest.json | jq --raw-output ".artifacts[]?.path | select( . != null )" > uploads.txt
120+
echo "uploading..."
121+
cat uploads.txt
122+
gh release upload ${{ github.ref_name }} $(cat uploads.txt)
123+
echo "uploaded!"
124+
125+
# Mark the Github Release™ as a non-draft now that everything has succeeded!
126+
publish-release:
127+
# Only run after all the other tasks, but it's ok if upload-artifacts was skipped
128+
needs: [create-release, upload-artifacts]
129+
if: ${{ always() && needs.create-release.result == 'success' && (needs.upload-artifacts.result == 'skipped' || needs.upload-artifacts.result == 'success') }}
130+
runs-on: ubuntu-latest
131+
env:
132+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
steps:
134+
- uses: actions/checkout@v3
135+
- name: mark release as non-draft
136+
run: |
137+
gh release edit ${{ github.ref_name }} --draft=false

.github/workflows/test.yml

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
fmt:
10+
name: Rustfmt
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
profile: minimal
17+
toolchain: stable
18+
override: true
19+
- run: rustup component add rustfmt
20+
- uses: actions-rs/cargo@v1
21+
with:
22+
command: fmt
23+
args: --all -- --check
24+
25+
clippy:
26+
name: Clippy
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- uses: actions-rs/toolchain@v1
31+
with:
32+
toolchain: stable
33+
components: clippy
34+
override: true
35+
- uses: actions-rs/clippy-check@v1
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
args: --all-features
39+
name: Clippy Output
40+
41+
docs:
42+
runs-on: ubuntu-latest
43+
name: Docs
44+
steps:
45+
- uses: actions/checkout@v3
46+
with:
47+
submodules: true
48+
- name: Install
49+
uses: actions-rs/toolchain@v1
50+
with:
51+
profile: minimal
52+
toolchain: stable
53+
override: true
54+
- name: cargo doc
55+
run: cargo doc --no-deps --all-features
56+
env:
57+
RUSTDOCFLAGS: --cfg docsrs
58+
59+
test:
60+
name: Test
61+
env:
62+
PROJECT_NAME_UNDERSCORE: batsim
63+
CARGO_INCREMENTAL: 0
64+
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
65+
RUSTDOCFLAGS: -Cpanic=abort
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v3
69+
- uses: actions-rs/toolchain@v1
70+
with:
71+
profile: minimal
72+
toolchain: nightly
73+
override: true
74+
- name: Cache dependencies
75+
uses: actions/cache@v3
76+
env:
77+
cache-name: cache-dependencies
78+
with:
79+
path: |
80+
~/.cargo/.crates.toml
81+
~/.cargo/.crates2.json
82+
~/.cargo/bin
83+
~/.cargo/registry/index
84+
~/.cargo/registry/cache
85+
target
86+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
87+
- name: Generate test result and coverage report
88+
run: |
89+
cargo install cargo2junit grcov;
90+
cargo test $CARGO_OPTIONS -v -- -Z unstable-options --format json | cargo2junit > results.xml;
91+
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
92+
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
93+
- name: Upload test results
94+
uses: EnricoMi/publish-unit-test-result-action@v2
95+
with:
96+
check_name: Test Results
97+
github_token: ${{ secrets.GITHUB_TOKEN }}
98+
files: results.xml
99+
# - name: Upload to CodeCov
100+
# uses: codecov/codecov-action@v1
101+
# with:
102+
# # required for private repositories:
103+
# token: ${{ secrets.CODECOV_TOKEN }}
104+
# files: ./lcov.info
105+
# fail_ci_if_error: true
106+
107+
- name: Send build success notification
108+
if: success()
109+
uses: rtCamp/[email protected]
110+
env:
111+
SLACK_MESSAGE: ${{ github.repository }} build ${{ github.run_number }} launched by ${{ github.actor }} has succeeded
112+
SLACK_TITLE: Build Success
113+
SLACK_CHANNEL: city-modelling-feeds
114+
SLACK_USERNAME: GitHub Build Bot
115+
SLACK_ICON: https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-12-19/288981919427_f45f04edd92902a96859_512.png
116+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
117+
118+
- name: Send build failure notification
119+
if: failure()
120+
uses: rtCamp/[email protected]
121+
env:
122+
SLACK_COLOR: '#FF0000'
123+
SLACK_MESSAGE: ${{ github.repository }} build ${{ github.run_number }} launched by ${{ github.actor }} has failed
124+
SLACK_TITLE: Build Failure!
125+
SLACK_CHANNEL: city-modelling-feeds
126+
SLACK_USERNAME: GitHub Build Bot
127+
SLACK_ICON: https://slack-files2.s3-us-west-2.amazonaws.com/avatars/2017-12-19/288981919427_f45f04edd92902a96859_512.png
128+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
output_*
2+
tmp
3+
.vscode
4+
.idea
5+
default_*.profraw
6+
7+
# Added by cargo
8+
9+
/target
10+
/report

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# [v0.0.5]
2+
3+
Breaking change! Config files will need changing.
4+
5+
Moves 'trigger' out of the config battery group into it's own trigger_group (see docs and examples).
6+
7+
# [v0.0.2]
8+
9+
Adds "specs" field to charge events output.
10+
11+
# [v0.0.1]
12+
13+
Test release
14+
15+
# [v0.0.0]
16+
17+
Test release

CONTRIBUTING.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure your pull request does not include eroneous files, particualrly any data.
11+
2. Update the README.md.
12+
3. Format using `cargo fmt --all` (we are using lastest stable releases)
13+
3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
14+
do not have permission to do that, you may request the second reviewer to merge it for you.
15+
16+
## Code of Conduct
17+
18+
### Our Pledge
19+
20+
In the interest of fostering an open and welcoming environment, we as
21+
contributors and maintainers pledge to making participation in our project and
22+
our community a harassment-free experience for everyone, regardless of age, body
23+
size, disability, ethnicity, gender identity and expression, level of experience,
24+
nationality, personal appearance, race, religion, or sexual identity and
25+
orientation.
26+
27+
### Our Standards
28+
29+
Examples of behavior that contributes to creating a positive environment
30+
include:
31+
32+
* Using welcoming and inclusive language
33+
* Being respectful of differing viewpoints and experiences
34+
* Gracefully accepting constructive criticism
35+
* Focusing on what is best for the community
36+
* Showing empathy towards other community members
37+
38+
Examples of unacceptable behavior by participants include:
39+
40+
* The use of sexualized language or imagery and unwelcome sexual attention or
41+
advances
42+
* Trolling, insulting/derogatory comments, and personal or political attacks
43+
* Public or private harassment
44+
* Publishing others' private information, such as a physical or electronic
45+
address, without explicit permission
46+
* Other conduct which could reasonably be considered inappropriate in a
47+
professional setting
48+
49+
### Our Responsibilities
50+
51+
Project maintainers are responsible for clarifying the standards of acceptable
52+
behavior and are expected to take appropriate and fair corrective action in
53+
response to any instances of unacceptable behavior.
54+
55+
Project maintainers have the right and responsibility to remove, edit, or
56+
reject comments, commits, code, wiki edits, issues, and other contributions
57+
that are not aligned to this Code of Conduct, or to ban temporarily or
58+
permanently any contributor for other behaviors that they deem inappropriate,
59+
threatening, offensive, or harmful.
60+
61+
### Scope
62+
63+
This Code of Conduct applies both within project spaces and in public spaces
64+
when an individual is representing the project or its community. Examples of
65+
representing a project or community include using an official project e-mail
66+
address, posting via an official social media account, or acting as an appointed
67+
representative at an online or offline event. Representation of a project may be
68+
further defined and clarified by project maintainers.
69+
70+
### Enforcement
71+
72+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
73+
reported by contacting the project team at [citymodelling#arup.com]. All
74+
complaints will be reviewed and investigated and will result in a response that
75+
is deemed necessary and appropriate to the circumstances. The project team is
76+
obligated to maintain confidentiality with regard to the reporter of an incident.
77+
Further details of specific enforcement policies may be posted separately.
78+
79+
Project maintainers who do not follow or enforce the Code of Conduct in good
80+
faith may face temporary or permanent repercussions as determined by other
81+
members of the project's leadership.
82+
83+
### Attribution
84+
85+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
86+
available at [http://contributor-covenant.org/version/1/4][version]
87+
88+
[homepage]: http://contributor-covenant.org
89+
[version]: http://contributor-covenant.org/version/1/4/

0 commit comments

Comments
 (0)