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

[Merged by Bors] - run some examples on CI using swiftshader #1826

Closed
wants to merge 8 commits into from

Conversation

mockersf
Copy link
Member

@mockersf mockersf commented Apr 5, 2021

From suggestion from Godot workflows: #1730 (comment)

  • Add a feature bevy_debug that will make Bevy read a debug config file to setup some debug systems
    • Currently, only one that will exit after x frames
    • Could add option to dump screen to image file once that's possible
  • Add a job in CI workflow that will run a few examples using swiftshader
    • This job takes around 13 minutes, so doesn't add to global CI duration
example number of frames duration
alien_cake_addict 300 1:50
breakout 1800 0:44
contributors 1800 0:43
load_gltf 300 2:37
scene 1800 0:44

@alice-i-cecile alice-i-cecile added A-Build-System Related to build systems or continuous integration C-Examples An addition or correction to our examples A-Rendering Drawing game state to the screen labels Apr 5, 2021
@alice-i-cecile
Copy link
Member

Should we be mocking input for the game examples as well? It would be nice to catch regressions there too.

@mockersf
Copy link
Member Author

mockersf commented Apr 5, 2021

This could be a nice later evolution, adding for example to the debug config file a list of (frame_number, event_to_send). That's why I think having a debug configuration and associated feature is a nice way for this

@mockersf mockersf changed the title run some examples on CI run some examples on CI using swiftshader Apr 5, 2021
@@ -0,0 +1,3 @@
(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would claim that specifying which example to run in the config would be wise, which would be useful to test diverging paths once we accept input.

Copy link
Member Author

@mockersf mockersf Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after thinking about this, I would prefer to keep the example name outside and instead allow file like breakout-1.ron, breakout-2.ron, ...
having the name inside means that:

  • to get it from CI we have to parse the ron in the GitHub action
  • once the example started, it is not useful anymore

what do you think?

Copy link
Member

@cart cart Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm for now I'm cool with using it as-is. Maybe long term we can write a rust program that orchestrates the tests / parses + runs the ron files. Then the github action could just run the rust program.

Embedding the app file name it in the test name creates "collision problems". Ex: what if we create a breakout-1.rs example?

Cargo.toml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved

- name: Setup swiftshader
run: |
wget https://github.com/qarmin/gtk_library_store/releases/download/3.24.0/swiftshader.zip;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we trust this? The repo doesn't have any readme or sources and doesn't tell how it was built. In addition there was exactly a single release. I think it would be better if we made a repo in the bevyengine org that uses CI to build swiftshader and download this pre-compiled version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

origin from this download: godotengine/godot#38428 (comment)

I think we can trust it, but I agree it would be better to have a version owned by Bevy. I can setup a repo once Cart creates it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm as long as we aren't passing in secrets, do we need to trust it? Whats the worst case scenario here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing really bad, mostly breaking our CI by changing/removing the download. Also we don't have the possibility to update if we need to

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the github token passed for branch pushes (eg bors r+) has write access as far as I know. I don't know if it is possible to access it some way if it isn't explicitly used in the workflow file though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the github token definitely has write access. I hope workflows only have access if it is explicitly passed in to a command in the workflow file. Otherwise we should reconsider our use of things like superlinter

Copy link
Member Author

@mockersf mockersf Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ci during branch push is not triggered by Bors but by the event push on branch staging, I would consider it a big bug in GitHub Actions if Bors token leaked here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need write permission to push to a branch. If the github token is explicitly referenced in the workflow file it is definitively possible to use it to write things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've dug into this a bit deeper. Everything I've read indicates that secrets are not accessible by a workflow container unless explicitly passed in. I don't have the bandwidth to do a full pen-test here, so I'll just trust what I've read (and the knowledge that if it didn't behave the way we've discussed, there would be very serious security implications that would completely erode people's trust in github).

Copy link
Member Author

@mockersf mockersf Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we discussed this a bit today, secrets are not accessible during pr tests, and the GITHUB_TOKEN, should someone add it in an action, would be a readonly token


- name: Build bevy
run: |
cargo build --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_wgpu,bevy_winit,render,png,hdr,x11,bevy_debug"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long will the CI job take when compiling in release mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was a few minutes longer overall in release: https://github.com/mockersf/bevy/runs/2271841611?check_suite_focus=true

@cart
Copy link
Member

cart commented Apr 13, 2021

I think this is a solid first step into automated "end-to-end" bevy tests. I sort of expect the ron-config to eventually be overly limiting, but I think it works perfectly for the current "does example run without crashing" style of test. For more complicated tests we'll likely want full control of the app. It would be interesting to explore ways to "inject" code-driven tests into pre-written apps (ex: click this thing, wait 10 seconds, then run this system that checks the value of a resource or validates pixels rendered to the screen).

Maybe something like what we used to do for android example:

// only works for single file examples
include!("../3d/3d_scene.rs");

// enable a `bevy_app` feature that somehow injects this plugin into the App above? maybe not possible
struct TestPlugin;

impl Plugin for TestPlugin {
  // add test systems/resources here
} 

Or alternatively we just create new Apps/files for the more complicated tests.

@cart
Copy link
Member

cart commented Apr 14, 2021

bors r+

bors bot pushed a commit that referenced this pull request Apr 14, 2021
From suggestion from Godot workflows: #1730 (comment)

* Add a feature `bevy_debug` that will make Bevy read a debug config file to setup some debug systems
  * Currently, only one that will exit after x frames
  * Could add option to dump screen to image file once that's possible
* Add a job in CI workflow that will run a few examples using [`swiftshader`](https://github.com/google/swiftshader)
  * This job takes around 13 minutes, so doesn't add to global CI duration

|example|number of frames|duration|
|-|-|-|
|`alien_cake_addict`|300|1:50|
|`breakout`|1800|0:44|
|`contributors`|1800|0:43|
|`load_gltf`|300|2:37|
|`scene`|1800|0:44|
@bors bors bot changed the title run some examples on CI using swiftshader [Merged by Bors] - run some examples on CI using swiftshader Apr 14, 2021
@bors bors bot closed this Apr 14, 2021
@cart
Copy link
Member

cart commented Apr 14, 2021

Just realized that bors doesn't run the new tests 😄

@mockersf can you add the new job name to this file?
https://github.com/bevyengine/bevy/blob/main/.github/bors.toml

@mockersf
Copy link
Member Author

Just realized that bors doesn't run the new tests 😄

@mockersf can you add the new job name to this file?
https://github.com/bevyengine/bevy/blob/main/.github/bors.toml

oh missed that file :(

bors bot pushed a commit that referenced this pull request Apr 15, 2021
followup on #1826 (comment): adding the new job to Bors
ostwilkens pushed a commit to ostwilkens/bevy that referenced this pull request Jul 27, 2021
From suggestion from Godot workflows: bevyengine#1730 (comment)

* Add a feature `bevy_debug` that will make Bevy read a debug config file to setup some debug systems
  * Currently, only one that will exit after x frames
  * Could add option to dump screen to image file once that's possible
* Add a job in CI workflow that will run a few examples using [`swiftshader`](https://github.com/google/swiftshader)
  * This job takes around 13 minutes, so doesn't add to global CI duration

|example|number of frames|duration|
|-|-|-|
|`alien_cake_addict`|300|1:50|
|`breakout`|1800|0:44|
|`contributors`|1800|0:43|
|`load_gltf`|300|2:37|
|`scene`|1800|0:44|
ostwilkens pushed a commit to ostwilkens/bevy that referenced this pull request Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Build-System Related to build systems or continuous integration A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants