Initial Commit #1
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: javaplayground | |
GH_CONTAINER_REGISTRY_USERNAME: bowbahdoe | |
AWS_ACCESS_KEY_ID: AKIAWESVHZ3JQAY5NM5K | |
jobs: | |
build_compiler_containers: | |
name: Build ${{ matrix.runtime }} container | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- runtime: latest | |
TARGZ_URL: https://download.java.net/java/GA/jdk22.0.2/c9ecb94cd31b495da20a27d4581645e8/9/GPL/openjdk-22.0.2_linux-x64_bin.tar.gz | |
TARGZ_SHA: 41536f115668308ecf4eba92aaf6acaeb0936225828b741efd83b6173ba82963 | |
TARGZ_FOLDER: jdk-22.0.2 | |
- runtime: valhalla | |
TARGZ_URL: https://download.java.net/java/early_access/valhalla/1/openjdk-23-valhalla+1-90_linux-x64_bin.tar.gz | |
TARGZ_SHA: 5235afaf5ecc86f2237458cf40f8ed965939372f606edbd0fc46e1ee2e69f5f5 | |
TARGZ_FOLDER: jdk-23 | |
- runtime: early_access | |
TARGZ_URL: https://download.java.net/java/early_access/jdk23/34/GPL/openjdk-23-ea+34_linux-x64_bin.tar.gz | |
TARGZ_SHA: 9d3fa4fbb8247f3a47788c52c09ac5c265e023cfda821610ade2a43104bdaace | |
TARGZ_FOLDER: jdk-23 | |
if: 'github.event_name == ''push'' || contains(github.event.pull_request.labels.*.name, ''CI: approved'')' | |
env: | |
IMAGE_NAME: ghcr.io/bowbahdoe/run-java-code-ci-${{ matrix.runtime }} | |
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@v3 | |
with: | |
registry: ghcr.io | |
username: "${{ github.actor }}" | |
password: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Build and push container | |
uses: docker/build-push-action@v4 | |
with: | |
context: compiler/base/ | |
file: compiler/base/Dockerfile | |
build-args: |- | |
TARGZ_URL=${{ matrix.TARGZ_URL }} | |
TARGZ_SHA=${{ matrix.TARGZ_SHA }} | |
TARGZ_FOLDER=${{ matrix.TARGZ_FOLDER }} | |
pull: true | |
push: true | |
tags: "${{ env.IMAGE_NAME }}:${{ github.run_id }}" | |
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: Build backend | |
run: |- | |
mkdir -p ui/target; docker run --rm -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 | |
release_artifacts: | |
name: Release artifacts | |
runs-on: ubuntu-latest | |
needs: | |
- build_compiler_containers | |
- build_backend | |
- build_frontend | |
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@v3 | |
with: | |
registry: ghcr.io | |
username: "${{ github.actor }}" | |
password: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: "${{ env.DOCKER_HUB_USERNAME }}" | |
password: "${{ secrets.DOCKER_HUB_TOKEN }}" | |
- name: Pull containers | |
run: |- | |
for c in latest early_access valhalla; do | |
docker pull ghcr.io/bowbahdoe/run-java-code-ci-$c:${{ github.run_id }} | |
done | |
- name: Rename containers | |
run: |- | |
for c in latest early_access valhalla; do | |
docker tag ghcr.io/bowbahdoe/run-java-code-ci-$c:${{ github.run_id }} javaplayground/$c | |
done | |
- name: Push containers | |
run: |- | |
for c in latest early_access valhalla; do | |
docker push javaplayground/$c | |
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 | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::762254388821:role/java-playground-github-actions-role | |
aws-region: us-east-2 | |
- name: Push backend | |
run: aws s3 cp server/ui s3://java-playground-artifacts | |
- name: Push frontend | |
run: aws s3 sync server/build/ s3://java-playground-artifacts/build |