Merge pull request #964 from rust-lang/hard-stop #704
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file was generated by ci/generate and should not be modified by hand | |
--- | |
name: Validate everything | |
'on': | |
push: | |
pull_request_target: | |
types: | |
- labeled | |
branches: | |
- main | |
env: | |
DOCKER_HUB_USERNAME: shepmaster | |
GH_CONTAINER_REGISTRY_USERNAME: shepmaster | |
AWS_ACCESS_KEY_ID: AKIAWESVHZ3JQAY5NM5K | |
jobs: | |
build_compiler_containers: | |
name: Build ${{ matrix.channel }} compiler container | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
channel: | |
- stable | |
- beta | |
- nightly | |
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')' | |
env: | |
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-rust-${{ matrix.channel }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: image=moby/buildkit:v0.11.6 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}" | |
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}" | |
- name: Build and push 'toolchain' container | |
env: | |
TAG_PREFIX: "${{ env.IMAGE_NAME }}:toolchain" | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/base/ | |
file: compiler/base/Dockerfile | |
build-args: channel=${{ matrix.channel }} | |
target: toolchain | |
pull: true | |
push: true | |
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}" | |
cache-from: |- | |
${{ env.TAG_PREFIX }}--${{ github.run_id }} | |
${{ env.TAG_PREFIX }}--latest | |
cache-to: type=inline | |
- name: Build and push 'bare-sources' container | |
env: | |
TAG_PREFIX: "${{ env.IMAGE_NAME }}:bare-sources" | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/base/ | |
file: compiler/base/Dockerfile | |
build-args: channel=${{ matrix.channel }} | |
target: bare-sources | |
pull: true | |
push: true | |
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}" | |
cache-from: |- | |
${{ env.TAG_PREFIX }}--${{ github.run_id }} | |
${{ env.TAG_PREFIX }}--latest | |
cache-to: type=inline | |
- name: Build and push 'munge' container | |
env: | |
TAG_PREFIX: "${{ env.IMAGE_NAME }}:munge" | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/base/ | |
file: compiler/base/Dockerfile | |
build-args: channel=${{ matrix.channel }} | |
target: munge | |
pull: true | |
push: true | |
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}" | |
cache-from: |- | |
${{ env.TAG_PREFIX }}--${{ github.run_id }} | |
${{ env.TAG_PREFIX }}--latest | |
cache-to: type=inline | |
- name: Build and push 'sources' container | |
env: | |
TAG_PREFIX: "${{ env.IMAGE_NAME }}:sources" | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/base/ | |
file: compiler/base/Dockerfile | |
build-args: channel=${{ matrix.channel }} | |
target: sources | |
pull: true | |
push: true | |
tags: "${{ env.TAG_PREFIX }}--${{ github.run_id }}" | |
cache-from: |- | |
${{ env.TAG_PREFIX }}--${{ github.run_id }} | |
${{ env.TAG_PREFIX }}--latest | |
cache-to: type=inline | |
- name: Build and push container | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/base/ | |
file: compiler/base/Dockerfile | |
build-args: channel=${{ matrix.channel }} | |
pull: true | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}" | |
cache-from: |- | |
${{ env.IMAGE_NAME }}:${{ github.run_id }} | |
${{ env.IMAGE_NAME }}:latest | |
cache-to: type=inline | |
build_tool_containers: | |
name: Build ${{ matrix.tool }} tool container | |
runs-on: ubuntu-latest | |
needs: build_compiler_containers | |
strategy: | |
matrix: | |
tool: | |
- clippy | |
- miri | |
- rustfmt | |
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')' | |
env: | |
IMAGE_NAME: ghcr.io/integer32llc/rust-playground-ci-tool-${{ matrix.tool }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: image=moby/buildkit:v0.11.6 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}" | |
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}" | |
- name: Build and push container | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/${{ matrix.tool }}/ | |
file: compiler/${{ matrix.tool }}/Dockerfile | |
build-args: base_image=ghcr.io/integer32llc/rust-playground-ci-rust-nightly:sources--${{ github.run_id }} | |
pull: true | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}" | |
cache-from: |- | |
${{ env.IMAGE_NAME }}:${{ github.run_id }} | |
${{ env.IMAGE_NAME }}:latest | |
cache-to: type=inline | |
build_backend: | |
name: Build backend | |
runs-on: ubuntu-latest | |
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Cache Cargo intermediate products | |
uses: actions/cache@v3 | |
with: | |
path: |- | |
~/.cargo/registry | |
~/.cargo/git | |
ui/target | |
key: "${{ runner.os }}-cargo-${{ hashFiles('ui/**/Cargo.lock') }}-2" | |
- name: Format server | |
run: cargo fmt --manifest-path ui/Cargo.toml --all --check | |
- name: Format top-crates | |
run: cargo fmt --manifest-path top-crates/Cargo.toml --check | |
- name: Format orchestrator | |
run: cargo fmt --manifest-path compiler/base/orchestrator/Cargo.toml --check | |
- name: Build backend | |
run: |- | |
mkdir -p ui/target; docker run --rm -v $PWD/compiler/base/asm-cleanup:/compiler/base/asm-cleanup -v $PWD/compiler/base/orchestrator:/compiler/base/orchestrator -v $PWD/compiler/base/modify-cargo-toml:/compiler/base/modify-cargo-toml -v $PWD/ui:/ui -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry --workdir /ui rust:alpine sh -c ' | |
apk add musl-dev openssl-dev openssl-libs-static | |
# Adding -C relocation-model=static due to | |
# https://github.com/rust-lang/rust/issues/95926 | |
# Adding this to find the statically-built version | |
export OPENSSL_NO_PKG_CONFIG=1 OPENSSL_STATIC=1 OPENSSL_DIR=/usr/ | |
# Unit tests | |
cargo rustc --tests --locked -- -C relocation-model=static; | |
test_bin=$(find target/debug/deps/ -name "ui*" -type f -perm -a=x); | |
mv "${test_bin}" target/unit_tests; | |
# Primary binary | |
cargo rustc --locked --release -- -C relocation-model=static; | |
mv target/release/ui target/ui; | |
' | |
- name: Restore permissions | |
run: sudo chown -R runner:docker ~/.cargo/ ui/target | |
- name: Save backend artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: backend | |
path: | | |
ui/target/ui | |
ui/target/unit_tests | |
build_frontend: | |
name: Build frontend | |
runs-on: ubuntu-latest | |
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
- name: Cache yarn intermediate products | |
uses: actions/cache@v3 | |
with: | |
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}" | |
key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}" | |
restore-keys: "${{ runner.os }}-yarn-" | |
- name: Configure node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.14 | |
- name: Install dependencies | |
run: yarn --cwd ui/frontend/ | |
- name: Run tests | |
run: yarn --cwd ui/frontend/ test | |
- name: Lint | |
run: yarn --cwd ui/frontend/ test:lint | |
- name: Style | |
run: yarn --cwd ui/frontend/ test:style | |
- name: Build frontend | |
run: yarn --cwd ui/frontend/ run build:production | |
- name: Save frontend artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: frontend | |
path: ui/frontend/build | |
run_integration_tests: | |
name: Running integration tests | |
runs-on: ubuntu-latest | |
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')' | |
needs: | |
- build_compiler_containers | |
- build_tool_containers | |
- build_backend | |
- build_frontend | |
defaults: | |
run: | |
working-directory: tests | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: "${{ github.event.pull_request.head.sha }}" | |
- name: Configure Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.0.2 | |
- name: Cache bundler intermediate products | |
uses: actions/cache@v3 | |
with: | |
path: tests/vendor/bundle | |
key: "${{ runner.os }}-gems-${{ hashFiles('tests/**/Gemfile.lock') }}" | |
restore-keys: "${{ runner.os }}-gems-" | |
- name: Install gems | |
run: |- | |
gem install bundler | |
bundle config path vendor/bundle | |
bundle install --jobs 4 --retry 3 | |
- name: Pull containers | |
run: echo ghcr.io/integer32llc/rust-playground-ci-{rust-{stable,beta,nightly},tool-{clippy,rustfmt,miri}}:${{ github.run_id }} | xargs -n1 docker pull | |
- name: Rename containers | |
run: |- | |
for c in stable beta nightly; do | |
docker tag ghcr.io/integer32llc/rust-playground-ci-rust-$c:${{ github.run_id }} ghcr.io/integer32llc/rust-playground-ci-rust-$c | |
docker tag ghcr.io/integer32llc/rust-playground-ci-rust-$c:${{ github.run_id }} shepmaster/rust-$c | |
docker tag ghcr.io/integer32llc/rust-playground-ci-rust-$c:${{ github.run_id }} rust-$c | |
done | |
for t in clippy miri rustfmt; do | |
docker tag ghcr.io/integer32llc/rust-playground-ci-tool-$t:${{ github.run_id }} ghcr.io/integer32llc/rust-playground-ci-tool-$t | |
docker tag ghcr.io/integer32llc/rust-playground-ci-tool-$t:${{ github.run_id }} shepmaster/$t | |
docker tag ghcr.io/integer32llc/rust-playground-ci-tool-$t:${{ github.run_id }} $t | |
done | |
- name: Download backend | |
uses: actions/download-artifact@v3 | |
with: | |
name: backend | |
path: tests/server/ | |
- name: Download frontend | |
uses: actions/download-artifact@v3 | |
with: | |
name: frontend | |
path: tests/server/build/ | |
- name: Run unit tests | |
run: chmod +x ./server/unit_tests && ./server/unit_tests | |
- name: Run tests | |
env: | |
PLAYGROUND_UI_ROOT: server/build/ | |
PLAYGROUND_CORS_ENABLED: true | |
PLAYGROUND_GITHUB_TOKEN: "${{ secrets.PLAYGROUND_GITHUB_TOKEN }}" | |
run: |- | |
killall -q ui || true | |
chmod +x ./server/ui && ./server/ui & | |
bundle exec rspec | |
- name: Preserve screenshots | |
if: "${{ failure() }}" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-failures | |
path: tests/test-failures | |
release_artifacts: | |
name: Release artifacts | |
runs-on: ubuntu-latest | |
needs: | |
- run_integration_tests | |
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: "${{ env.GH_CONTAINER_REGISTRY_USERNAME }}" | |
password: "${{ secrets.GH_CONTAINER_REGISTRY_TOKEN }}" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: "${{ env.DOCKER_HUB_USERNAME }}" | |
password: "${{ secrets.DOCKER_HUB_TOKEN }}" | |
- name: Pull containers | |
run: echo ghcr.io/integer32llc/rust-playground-ci-{rust-{stable,beta,nightly},tool-{clippy,rustfmt,miri}}:${{ github.run_id }} | xargs -n1 docker pull | |
- name: Rename containers | |
run: |- | |
for c in stable beta nightly; do | |
docker tag ghcr.io/integer32llc/rust-playground-ci-rust-$c:${{ github.run_id }} ghcr.io/integer32llc/rust-playground-ci-rust-$c | |
docker tag ghcr.io/integer32llc/rust-playground-ci-rust-$c:${{ github.run_id }} shepmaster/rust-$c | |
docker tag ghcr.io/integer32llc/rust-playground-ci-rust-$c:${{ github.run_id }} rust-$c | |
done | |
for t in clippy miri rustfmt; do | |
docker tag ghcr.io/integer32llc/rust-playground-ci-tool-$t:${{ github.run_id }} ghcr.io/integer32llc/rust-playground-ci-tool-$t | |
docker tag ghcr.io/integer32llc/rust-playground-ci-tool-$t:${{ github.run_id }} shepmaster/$t | |
docker tag ghcr.io/integer32llc/rust-playground-ci-tool-$t:${{ github.run_id }} $t | |
done | |
- name: Push containers | |
run: |- | |
for c in stable beta nightly; do | |
docker push ghcr.io/integer32llc/rust-playground-ci-rust-$c | |
docker push shepmaster/rust-$c | |
done | |
for t in clippy miri rustfmt; do | |
docker push ghcr.io/integer32llc/rust-playground-ci-tool-$t | |
docker push shepmaster/$t | |
done | |
- name: Download backend | |
uses: actions/download-artifact@v3 | |
with: | |
name: backend | |
path: server/ | |
- name: Download frontend | |
uses: actions/download-artifact@v3 | |
with: | |
name: frontend | |
path: server/build/ | |
- name: Configure AWS credentials (i32) | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: "${{ env.AWS_ACCESS_KEY_ID }}" | |
aws-secret-access-key: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
aws-region: us-east-2 | |
- name: Push backend (i32) | |
run: aws s3 cp server/ui s3://playground-artifacts-i32 | |
- name: Push frontend (i32) | |
run: aws s3 sync server/build/ s3://playground-artifacts-i32/build | |
- name: Configure AWS credentials (rust-lang) | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-skip-session-tagging: true | |
role-to-assume: arn:aws:iam::890664054962:role/upload-playground-artifacts | |
aws-region: us-west-1 | |
- name: Push backend (rust-lang) | |
run: aws s3 cp server/ui s3://rust-playground-artifacts | |
- name: Push frontend (rust-lang) | |
run: aws s3 sync server/build/ s3://rust-playground-artifacts/build |