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 pa11y-ci for accesibility linting #1046

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b016436
Add pa11y-ci for accesibility linting
TrialDragon Feb 22, 2024
0ada9bd
Fix typo in ci.yml
TrialDragon Feb 22, 2024
fd574b3
Add installing zola to ci.yml
TrialDragon Feb 22, 2024
4f1a3c7
Try to make Zola run in background
TrialDragon Feb 22, 2024
64a60ba
Try to make Zola run in background, again
TrialDragon Feb 22, 2024
6afe97a
Try to make this work
TrialDragon Feb 22, 2024
0eea106
Try to make this work, again
TrialDragon Feb 22, 2024
dafbcba
Run puppeteer install.js in ci.yml
TrialDragon Feb 22, 2024
bff0dbb
Update .github/workflows/ci.yml
TrialDragon Feb 22, 2024
f43de95
Change name of pa11y-ci job to more appropriate accessibility-linting
TrialDragon Feb 22, 2024
b86b3ee
Enable echo to recognize backslashes
TrialDragon Feb 22, 2024
704b537
Switch chromium installation to apt
TrialDragon Feb 22, 2024
fd6de52
Fix package name typo
TrialDragon Feb 22, 2024
0260118
Remove generated files dependency
TrialDragon Feb 22, 2024
e5aaed0
Add assets placeholder
TrialDragon Feb 26, 2024
d60bec0
Merge branch 'main' into 396_add_accesibility_lints_to_ci
TrialDragon Feb 26, 2024
134c9a3
Add examples placeholder
TrialDragon Feb 26, 2024
81b9fcf
Fix indentation
TrialDragon Feb 27, 2024
41efe5d
Fix typos indentation
TrialDragon Feb 27, 2024
fee9f06
Fix assets indentation
TrialDragon Feb 27, 2024
3c1fd85
Fix mkdir in example dummy pages
TrialDragon Feb 27, 2024
a5c35b4
Fix directory name
TrialDragon Feb 27, 2024
97b0ba4
Restore dummy example code
TrialDragon Feb 27, 2024
a6ef82c
Merge branch 'main' into 396_add_accesibility_lints_to_ci
TrialDragon Feb 27, 2024
3b1d260
Fix the typo
TrialDragon Feb 27, 2024
44f801b
Add community dummy pages
TrialDragon Feb 27, 2024
78fd2a0
Fix missing quote mark
TrialDragon Feb 27, 2024
73cad26
Add sponsor link to donate dummy page
TrialDragon Feb 27, 2024
f4c228d
Add dummy errors page
TrialDragon Feb 27, 2024
f7e5a77
Fix typo
TrialDragon Feb 27, 2024
ba4b757
Add missing back ticks
TrialDragon Feb 27, 2024
3b355bb
Cleanup some of the dummy files
TrialDragon Feb 27, 2024
e036f5f
Merge branch 'main' into 396_add_accesibility_lints_to_ci
TrialDragon Mar 1, 2024
aa5545e
Make assets page accessible
TrialDragon Mar 1, 2024
57b28b0
Fix conflicting id issue in dummy pages
TrialDragon Mar 1, 2024
202afb1
Exclude github from accessibility linting
TrialDragon Mar 1, 2024
1fc2ebe
Try to exclude github again
TrialDragon Mar 1, 2024
a454790
Revert "Try to exclude github again"
TrialDragon Mar 1, 2024
f0101a6
Revert "Exclude github from accessibility linting"
TrialDragon Mar 1, 2024
38af6e1
Fix examples issues
TrialDragon Mar 1, 2024
873e5da
Remove github faq from accessibility linting
TrialDragon Mar 1, 2024
7174b69
Fix docs footer contrast
TrialDragon Mar 2, 2024
70af105
Make migration area tag higher contrast
TrialDragon Mar 2, 2024
13c02a0
Make diffs contrasting
TrialDragon Mar 2, 2024
f001207
Make anchor links higher contrast
TrialDragon Mar 2, 2024
ffc1326
Fix improper formatting
TrialDragon Mar 2, 2024
3c8e230
Add 0.10 news bloom image alternative text
TrialDragon Mar 2, 2024
92e65d5
Try to fix errors page
TrialDragon Mar 2, 2024
0daf2c0
Add alternative text to Bevy logo
TrialDragon Mar 2, 2024
266916f
Make "illegal" code contrasting
TrialDragon Mar 2, 2024
1de2b7a
Add more missing alternative texts
TrialDragon Mar 2, 2024
adf2989
Make `generate-*` and build-website need accesibility linting
TrialDragon Mar 3, 2024
18f945d
Merge branch 'main' into 396_add_accesibility_lints_to_ci
TrialDragon Mar 11, 2024
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
317 changes: 312 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,313 @@ jobs:

- name: Check clippy
run: cargo clippy --workspace -- -Dwarnings

accessibility-linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Create Dummy Generated Pages
run: |
echo "Assets"
mkdir content/assets content/assets/placeholder
echo -e "+++\ntitle = \"Bevy Assets\"\ntemplate = \"assets.html\"\n+++\n" > content/assets/_index.md
echo -e "+++\ntitle = \"placeholder\"\n+++\n" > content/assets/placeholder/_index.md
echo -e "+++\ntitle = \"Example\"\ndescription = \"Example post of assets section of site.\"\n[extra]\nlink = \"https://example.com\"\nlicenses = [\"Example License\"]\nbevy_versions = [\"x.y.x\"]\n+++\n" > content/assets/placeholder/example.md
echo "Examples"
mkdir content/examples content/examples/2d_rendering content/examples/2d_rendering/2d-shapes
echo -e "+++\ntitle = \"Bevy Examples in WebGL2\"\ntemplate = \"examples.html\"\nsort_by = \"weight\"\n[extra]\nheader_message = \"Examples (WebGL2)\"\n+++\n" > content/examples/_index.md
echo -e "+++\ntitle = \"2D Rendering\"\nsort_by = \"weight\"\nweight = 15\n+++\n" > content/examples/2d_rendering/_index.md
echo -e "+++\ntitle = \"2D Shapes\"\ntemplate = \"example.html\"\nweight = 0\ndescription = \"Renders simple 2D primitive shapes like circles and polygons\"\n[extra]\ntechnical_name = \"2d-shapes\"\nlink = \"/examples/2d_rendering/2d-shapes\"\nimage = \"../static/screenshots/2d_rendering/2d_shapes.png\"\ncode_path = \"content/examples/2d_rendering/2d-shapes/2d_shapes.rs\"\ngithub_code_path = \"examples/2d/2d_shapes.rs\"\nheader_message = \"examples (WebGL2)\"\n+++\n" > content/examples/2d_rendering/2d-shapes/index.md
echo "//! Shows how to render simple primitive shapes with a single color.
use bevy::{
prelude::*,
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
const X_EXTENT: f32 = 600.;
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands.spawn(Camera2dBundle::default());
let shapes = [
Mesh2dHandle(meshes.add(Circle { radius: 50.0 })),
Mesh2dHandle(meshes.add(Ellipse::new(25.0, 50.0))),
Mesh2dHandle(meshes.add(Capsule2d::new(25.0, 50.0))),
Mesh2dHandle(meshes.add(Rectangle::new(50.0, 100.0))),
Mesh2dHandle(meshes.add(RegularPolygon::new(50.0, 6))),
Mesh2dHandle(meshes.add(Triangle2d::new(
Vec2::Y * 50.0,
Vec2::new(-50.0, -50.0),
Vec2::new(50.0, -50.0),
))),
];
let num_shapes = shapes.len();
for (i, shape) in shapes.into_iter().enumerate() {
// Distribute colors evenly across the rainbow.
let color = Color::hsl(360. * i as f32 / num_shapes as f32, 0.95, 0.7);
commands.spawn(MaterialMesh2dBundle {
mesh: shape,
material: materials.add(color),
transform: Transform::from_xyz(
// Distribute shapes from -X_EXTENT to +X_EXTENT.
-X_EXTENT / 2. + i as f32 / (num_shapes - 1) as f32 * X_EXTENT,
0.0,
0.0,
),
..default()
});
}
}" > content/examples/2d_rendering/2d-shapes/2d_shapes.rs
echo "Community"
mkdir content/community/donate content/community/people content/community/people/'community members' content/community/people/'the bevy organization'
echo "Donation Page"
echo -e "+++
title = \"Supporting Bevy Development\"
sort_by = \"weight\"
template = \"donate.html\"
weight = 1

[extra]
header_message = \"Supporting Bevy\"
sort_order_reversed = false

+++
" > content/community/donate/_index.md
echo -e "+++
title = \"Test Person\"
weight = 0

[extra]
profile_picture = \"\"
sponsor = \"nothing\"
bio = \"Test person.\"
discord = \"test#9999\"
discord_userid = \"000000000000000000\"
github = \"invalid\"
mastodon_user = \"invalid\"
mastodon_instance = \"doesnt.exist\"
twitter = \"nothing\"
itch_io = \"nada\"
roles = [\"Non-existent\"]

+++
" > content/community/donate/test.md
echo "People Page"
echo -e "+++
title = \"People\"
sort_by = \"weight\"
template = \"people.html\"
weight = 0

[extra]
header_message = \"People\"
sort_order_reversed = false

+++
" > content/community/people/_index.md
echo -e "+++
title = \"Community Members\"
sort_by = \"weight\"
weight = 2

[extra]
sort_order_reversed = false

+++
" > content/community/people/'community members'/_index.md
echo -e "+++
title = \"Test Person\"
weight = 0

[extra]
profile_picture = \"\"
sponsor = \"nothing\"
bio = \"Tester\"
discord = \"test\"
discord_userid = \"000000000000000000\"
github = \"test\"
itch_io = \"test\"
website = \"https://example.com\"

+++
" > content/community/people/'community members'/test.md
echo -e "+++
title = \"The Bevy Organization\"
sort_by = \"weight\"
weight = 1

[extra]
sort_order_reversed = false

+++
" > content/community/people/'the bevy organization'/_index.md
echo -e "+++
title = \"Test Member\"
weight = 0

[extra]
profile_picture = \"\"
bio = \"Test person.\"
discord = \"test#9999\"
discord_userid = \"000000000000000000\"
github = \"invalid\"
mastodon_user = \"invalid\"
mastodon_instance = \"doesnt.exist\"
twitter = \"nothing\"
itch_io = \"nada\"
roles = [\"Non-existent\"]

+++
" > content/community/people/'the bevy organization'/test.md
echo "Errors"
mkdir content/learn/errors
echo -e "+++
title = \"Errors\"
sort_by = \"weight\"
template = \"errors.html\"
weight = 0

[extra]
header_message = \"Errors\"
sort_order_reversed = false

+++
" > content/learn/errors/_index.md
echo -e "+++
title = \"B0001\"
weight = 0

+++


To keep [Rust rules on references](https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#the-rules-of-references) (either one mutable reference or any number of immutable references) on a component, it is not possible to have two queries on the same component when one requests mutable access to it in the same system.

Erroneous code example:

```rust
use bevy::prelude::*;

#[derive(Component)]
struct Player;

#[derive(Component)]
struct Enemy;

fn move_enemies_to_player(
mut enemies: Query<&mut Transform, With<Enemy>>,
player: Query<&Transform, With<Player>>,
) {
// ...
}

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, move_enemies_to_player)
.run();
}
```

This will panic, as it's not possible to have both a mutable and an immutable query on `Transform` at the same time.

You have two solutions:

Solution #1: use disjoint queries using [`Without`]

As a `Player` entity won't be an `Enemy` at the same time, those two queries will actually never target the same entity. This can be encoded in the query filter with [`Without`] :

[`Without`]: https://docs.rs/bevy/latest/bevy/ecs/query/struct.Without.html
```rust
use bevy::prelude::*;

#[derive(Component)]
struct Player;

#[derive(Component)]
struct Enemy;

fn move_enemies_to_player(
mut enemies: Query<&mut Transform, With<Enemy>>,
player: Query<&Transform, (With<Player>, Without<Enemy>)>,
) {
// ...
}

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, move_enemies_to_player)
.run();
}
```

Solution #2: use a `ParamSet`

A `ParamSet` will let you have conflicting queries as a parameter, but you will still be responsible for not using them at the same time in your system.

```rust
use bevy::prelude::*;

#[derive(Component)]
struct Player;

#[derive(Component)]
struct Enemy;

fn move_enemies_to_player(
mut transforms: ParamSet<(
Query<&mut Transform, With<Enemy>>,
Query<&Transform, With<Player>>,
)>,
) {
// ...
}

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, move_enemies_to_player)
.run();
}
```
" > content/learn/errors/test_error.md

- name: Install NPM
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install Google Chrome
run: |
sudo apt-get install -y chromium-browser
which chromium-browser
chromium-browser --version

- name: Install Zola
uses: taiki-e/install-action@v2
with:
tool: [email protected]

- name: Install Pa11y-CI and Wait-on
run: |
npm install pa11y-ci wait-on
node node_modules/puppeteer/install.js

- name: Run Pa11y-CI
run: |
echo -e "{\n \"defaults\": {\n \"chromeLaunchConfig\": {\n \"executablePath\": \"/usr/bin/chromium-browser\"\n }\n }\n}" > .pa11yci
zola serve &
npx wait-on http://127.0.0.1:1111
npx pa11y-ci --sitemap http://127.0.0.1:1111/sitemap.xml --sitemap-exclude 'faq'

typos:
runs-on: ubuntu-latest
Expand All @@ -81,7 +388,7 @@ jobs:
echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'

generate-assets:
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos]
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos, accessibility-linting]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -116,7 +423,7 @@ jobs:
retention-days: 1

generate-errors:
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos]
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos, accessibility-linting]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -143,7 +450,7 @@ jobs:
retention-days: 1

generate-wasm-examples:
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos]
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos, accessibility-linting]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -170,7 +477,7 @@ jobs:
retention-days: 1

generate-community:
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos]
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos, accessibility-linting]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -198,7 +505,7 @@ jobs:

build-website:
runs-on: ubuntu-latest
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos, generate-assets, generate-errors, generate-wasm-examples, generate-community]
needs: [mega-linter, test-code-examples, lint-tools, check-hide-lines, typos, accessibility-linting, generate-assets, generate-errors, generate-wasm-examples, generate-community]

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion content/learn/migration-guides/0.12-to-0.13.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ This means users who want to migrate their .meta files will have to add the `inc
</div>

- For `add_texture` you need to wrap your `AssetId` in `Some`
- `finish` now returns the atlas texture image directly instead of a handle. Provide the atlas texture to `add` on Assets<Texture> to get a Handle<Image>
- `finish` now returns the atlas texture image directly instead of a handle. Provide the atlas texture to `add` on `Assets<Texture>` to get a `Handle<Image>`

### [Remove the ability to ignore global volume](https://github.com/bevyengine/bevy/pull/11092)

Expand Down
2 changes: 1 addition & 1 deletion content/news/2020-08-10-introducing-bevy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1198,4 +1198,4 @@ If any of this sounds interesting to you, I encourage you to check out [Bevy on

I want Bevy to become a vibrant developer community ... thats actually why I chose the name! A Bevy is a group of birds, just like we are a group of game developers. Join the Bevy!

<img src="/assets/bevy_logo_dark.svg" style="height: 4.0rem; margin-top: 2.0rem" />
<img src="/assets/bevy_logo_dark.svg" alt="The Bevy logo" style="height: 4.0rem; margin-top: 2.0rem" />
Loading
Loading