Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
cdsupina committed Apr 26, 2024
2 parents 3ae62a0 + acd61c9 commit 41f5014
Show file tree
Hide file tree
Showing 55 changed files with 1,944 additions and 1,136 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ jobs:
- name: Check that the game compiles and is minimally sensible rust (no warnings)
run: cargo rustc --all-features -- -D warnings

- name: Check that the game compiles and is minimally sensible rust (no warnings) with just the arcade feature
run: cargo rustc --features arcade -- -D warnings

test:
name: ${{ matrix.name }}
needs: [style]
Expand Down
43 changes: 24 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ jobs:
build_release:
name: 🔨 Build
runs-on: ${{ matrix.config.os }}
continue-on-error: true
permissions:
id-token: write
contents: read
outputs:
release_version: ${{ env.RELEASE_VERSION }}
strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, target: "x86_64-unknown-linux-gnu" }
- { os: macos-latest, target: "x86_64-apple-darwin" }
- { os: macos-latest, target: "aarch64-apple-darwin" }
- { os: windows-latest, target: "x86_64-pc-windows-msvc" }
steps:
- name: 📠 Set Release Version
Expand All @@ -32,27 +31,35 @@ jobs:
- name: ⬇️ Checkout
uses: actions/checkout@v3

- name: 🧰 Install dependencies [Ubuntu]
- name: 🧰 Install Bevy dependencies [Ubuntu]
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y -q \
libasound2-dev \
libudev-dev
set -euxo pipefail
sudo apt update && sudo apt upgrade && sudo apt install -y lld g++ pkg-config libx11-dev libasound2-dev libudev-dev
- name: 🦀 Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
toolchain: nightly
profile: minimal
target: ${{ matrix.config.target }}

- name: 🔨 Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.config.target }}
args: --release --target ${{ matrix.config.target }} --features storage --features cli --features arcade

- name: Assume AWS IAM role
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::656454124102:role/ThetwaveGithubCiRole
aws-region: us-east-2

- name: Download Game image and audio assets from S3
shell: bash
run: |
./asset_manager.py --no-dryrun download
- name: ⚙️ Prepare artifacts [Windows]
shell: bash
Expand All @@ -62,9 +69,7 @@ jobs:
artifact_path="thetawave-${{ env.RELEASE_VERSION }}-${{ matrix.config.target }}.zip"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
mkdir $release_dir
cp target/${{ matrix.config.target }}/release/thetawave.exe $release_dir/
cp -R assets/ $release_dir/
cp LICENSE $release_dir/
cp -R assets LICENSE target/${{ matrix.config.target }}/release/thetawave.exe $release_dir/
7z a -tzip $artifact_path $release_dir/
- name: ⚙️ Prepare artifacts [Unix]
Expand All @@ -75,9 +80,7 @@ jobs:
artifact_path="thetawave-${{ env.RELEASE_VERSION }}-${{ matrix.config.target }}.tar.gz"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
mkdir $release_dir
cp target/${{ matrix.config.target }}/release/thetawave $release_dir/
cp -R assets $release_dir
cp LICENSE $release_dir
cp -R LICENSE assets target/${{ matrix.config.target }}/release/thetawave $release_dir/
tar -czvf $artifact_path $release_dir/
- name: ⏫️ Upload artifacts
Expand All @@ -92,6 +95,8 @@ jobs:
needs:
- build_release
runs-on: ubuntu-latest
permissions:
contents: write

steps:

Expand All @@ -117,4 +122,4 @@ jobs:
overwrite: true
body: 'Thetawave ${{ env.RELEASE_VERSION }}'
tag: ${{ github.ref }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export AWS_SESSION_TOKEN=$(aws sts assume-role --profile thetawavedev --output t
--role-arn arn:aws:iam::656454124102:role/ThetawaveDeveloperRole \
--role-session-name vpsession --query="Credentials.SessionToken" )
```
<<<<<<< HEAD

## Extra Nuglets

Expand All @@ -137,3 +138,37 @@ aws --profile <YOUR_AWS_PROFILE_NAME> s3 ls --recursive s3://assets-thetawave/pr
| awk '{print $4}' | sed 's/^premium_//' \ # Map into our "overlayed free-premium directory structure"
| xargs rm -f
```

### Accessing Assets in CI

As of 2023, the recommended way for automated tools like Github to access AWS S3 (for our game assets) is to use
[OIDC](https://en.wikipedia.org/wiki/OpenID) by allowing Github actions to assume an AWS IAM role with permissions to
read the bucket. [AWS](https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/)
and
[Github](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services)
both maintain documentation describing how to do this.

One of the repo maintainers owns an AWS IAM role with the "Trust relationships" defined as follows.

```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::012345678910:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
},
"StringLike": {
"token.actions.githubusercontent.com:sub": "repo:thetawave/thetawave:*"
}
}
}
]
}
```
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bevy_ecs = "0.13"
bevy_reflect = "0.13"
bevy_input = "0.13"
bevy_kira_audio = { version = "0.19", features = ["mp3", "wav"] }
leafwing-input-manager = "0.13"
leafwing-input-manager = {git = "https://github.com/Leafwing-Studios/leafwing-input-manager", rev = "29a9458"}
ron = "0.8.0"
bevy_time = "0.13"
bevy_math = "0.13"
Expand Down
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,50 @@ Thetawave is a physics-based space shooter with procedurally generated levels, d
**Special Mechanics:**
- Letting cargo hauler mobs reach the bottom of the arena heals the defense bar.

## Building and Playing Locally

While you can play [in the browser](https://thetawave.metalmancy.tech) (works best on Google Chrome...for now), you can
play offline in a few ways. The simplest way to play a native build of the game offline is to download the latest
[Github release](https://github.com/thetawavegame/thetawave/releases) for Windows or Linux. Then run the executable.

To run the game after compiling locally, do the following.

0. Clone the repository `git clone https://github.com/thetawavegame/thetawave.git`
0. Download our assets.

One way is to download a recent Linux `.tar.gz` release, and extract the `assets/` directory in the tarball into your
local `assets/` directory. We do so in the following Bash command. In Windows, just copy the files manually. Replace
the link with that of a build from the [latest release](https://github.com/thetawavegame/thetawave/releases),
especially if you are running off of the `main` branch.

```bash

curl -Ls https://github.com/thetawavegame/thetawave/releases/download/v0.2.0/thetawave-0.2.0-x86_64-unknown-linux-gnu.tar.gz \
| tar -xz -C assets/ --strip-components=2 --wildcards "*/assets/*"
```

If when running the `main` branch you still have missing assets, it means that we are using assets that are not yet
published in a release. In that case, you might checkout the latest tag. Find it by running `git tag` and then
execute, for example, `git checkout v0.2.0`.

0. Compile/run using [Cargo](https://github.com/rust-lang/cargo) as follows.

```bash
cargo run --release
```

0. Enable the install features you want. Our install features are as follows.

- `cli` - Enables start up parameters on the built `thetawave` executable.
- `storage` - Enables writing user stats to a local [SQLite](https://www.sqlite.org/) database.
- `arcade` - Enables arcade-specific features, namely through serial communication to a microcontroller.

One can run using install features as follows.

```bash
cargo run --release --features "storage,cli,arcade"
```

## How to Contribute

We welcome contributions from all community members. Your insights and improvements help us grow.
Expand Down
13 changes: 7 additions & 6 deletions asset_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""Download and upload Thetawave assets to our S3 bucket. This CLI basically wraps the `aws s3 sync` command. See the
CONTRIBUTING.md for more information on executing this script, including properly setting up credentials."""
from __future__ import annotations
from argparse import (
ArgumentParser,
Namespace,
Expand Down Expand Up @@ -31,8 +32,8 @@ class S3Location(str, Enum):


class TWAssetCLIArgs(Namespace):
profile: str
command: S3Action
profile: str | None
s3_location: S3Location
dryrun: bool

Expand All @@ -50,8 +51,9 @@ def get_parser() -> ArgumentParser:
help="""The name of the AWS profile that can access a role for manipulating the thetawave bucket. This profile
must be permissioned to use the AWS IAM role arn:aws:iam::656454124102:role/ThetawaveDeveloperRole . Your
default profile _probably_ doesnt/shouldn't correspond to your thetawave developer IAM user account, so you
probably need to set this.""",
required=True,
probably need to set this. If this is nor provided, AWS specified waterfall logic determines the credentials
used to access the S3 bucket. https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html""",
required=False,
)
res.add_argument(
"--dryrun",
Expand Down Expand Up @@ -79,8 +81,7 @@ def run(args: TWAssetCLIArgs) -> None:
src_dest = [s3_loc, "assets/"] if args.command == S3Action.DOWNLOAD else ["assets/", s3_loc]
action_args = [
"aws",
"--profile",
args.profile,
*(["--profile", args.profile] if args.profile else []),
"s3",
"sync",
*("--exclude", "*.ron", "--exclude", "*.gif"),
Expand All @@ -92,7 +93,7 @@ def run(args: TWAssetCLIArgs) -> None:
if args.dryrun:
LOGGER.warning(
"""The asset manager was executed with the --dryrun flag. No action was taken. Rerun with
--no-dryrun if the desired files will be (down|up)loaded."""
--no-dryrun if the desired files will be (down|up)loaded."""
)


Expand Down
73 changes: 73 additions & 0 deletions assets/data/abilities.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
(
charge_ability: (
slot: Two,
base_cooldown_time: 0.8,
ability: (
action_time: 0.5,
incoming_damage_multiplier: 0.75,
impulse: 12000.0,
)
),
mega_blast_ability: (
slot: Two,
base_cooldown_time: 2.5,
ability: (
spread_pattern: Arc((
spread_weights: (0.5, 1.0),
max_spread: 1.57080,
projectile_gap: 3.14159,
)),
damage_multiplier: 5.0,
ammunition: Blast(Ally),
speed_multiplier: 2.0,
direction: 1.57080,
despawn_time_multiplier: 1.0,
size_multiplier: 5.0,
count_multiplier: 0.5,
sound: MegaBlastAbility,
),
),
standard_blast_ability: (
slot: One,
base_cooldown_time: 0.25,
ability: (
spread_pattern: Arc((
spread_weights: (0.5, 1.0),
max_spread: 1.57080,
projectile_gap: 3.14159,
)),
damage_multiplier: 1.0,
ammunition: Blast(Ally),
speed_multiplier: 1.0,
direction: 1.57080,
despawn_time_multiplier: 1.0,
size_multiplier: 1.0,
count_multiplier: 1.0,
sound: PlayerFireBlast,
),
),
standard_bullet_ability: (
slot: One,
base_cooldown_time: 0.3,
ability: (
spread_pattern: Random((
speed_range: (
start: 0.75,
end: 1.25,
),
angle_range: (
start: 1.37445,
end: 1.76715,
),
)),
damage_multiplier: 0.8,
ammunition: Bullet(Ally),
speed_multiplier: 1.0,
direction: 1.57080,
despawn_time_multiplier: 1.0,
size_multiplier: 1.0,
count_multiplier: 1.0,
sound: PlayerFireBlast,
),
),
)
Loading

0 comments on commit 41f5014

Please sign in to comment.