diff --git a/.gitea/actions/setup/action.yml b/.gitea/actions/setup/action.yml new file mode 100644 index 0000000..80da7ca --- /dev/null +++ b/.gitea/actions/setup/action.yml @@ -0,0 +1,37 @@ +name: Setup +description: Checkout code, restore caches, and install pnpm dependencies +inputs: + token: + required: true + +runs: + using: composite + steps: + - name: ๐Ÿ“‘ Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ inputs.token }} + + - name: ๐Ÿ’พ Setup pnpm Cache + uses: actions/cache@v4 + with: + path: .pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: ๐Ÿฆ€ Cache Cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: ๐Ÿ“ฆ Install Dependencies + shell: bash + run: pnpm install --frozen-lockfile --store-dir .pnpm-store diff --git a/.gitea/workflows/benchmark.yaml b/.gitea/workflows/benchmark.yaml index 1ae30c4..79afa07 100644 --- a/.gitea/workflows/benchmark.yaml +++ b/.gitea/workflows/benchmark.yaml @@ -12,40 +12,17 @@ env: CARGO_TARGET_DIR: target jobs: - release: + benchmark: runs-on: ubuntu-latest container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69 steps: - - name: ๐Ÿ“‘ Checkout Code - uses: actions/checkout@v4 + - name: ๐Ÿ”ง Setup + uses: ./.gitea/actions/setup with: - fetch-depth: 0 token: ${{ secrets.GITEA_TOKEN }} - - name: ๐Ÿ’พ Setup pnpm Cache - uses: actions/cache@v4 - with: - path: ${{ env.PNPM_CACHE_FOLDER }} - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: ๐Ÿฆ€ Cache Cargo - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - name: ๐Ÿ“ฆ Install Dependencies - run: pnpm install --frozen-lockfile --store-dir ${{ env.PNPM_CACHE_FOLDER }} - - - name: ๐Ÿ› ๏ธBuild Nodes + - name: ๐Ÿ› ๏ธ Build Nodes run: pnpm build:nodes - name: ๐Ÿƒ Execute Runtime @@ -56,7 +33,13 @@ jobs: mkdir -p ~/.ssh echo "${{ secrets.GIT_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan -p 2222 -H git.max-richter.dev >> ~/.ssh/known_hosts + cat >> ~/.ssh/config <<'EOF' + Host git.max-richter.dev + Port 2222 + IdentityFile ~/.ssh/id_ed25519 + IdentitiesOnly yes + EOF + ssh-keyscan -H git.max-richter.dev >> ~/.ssh/known_hosts - name: ๐Ÿ“ค Push Results env: @@ -65,23 +48,16 @@ jobs: git config --global user.name "nodarium-bot" git config --global user.email "nodarium-bot@max-richter.dev" - # 2. Clone the benchmarks repo into a temp folder - git config --global core.sshCommand "ssh -p 2222 -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes" git clone git@git.max-richter.dev:max/nodarium-benchmarks.git target_bench_repo - - # 3. Create a directory structure based on the branch - # This allows the UI to "switch between branches" - SAFE_PR_NAME=$(printf "%s" "$GITHUB_HEAD_REF" | tr '/' '-') + + BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" + SAFE_PR_NAME=$(printf "%s" "$BRANCH" | tr '/' '-') DEST_DIR="target_bench_repo/data/$SAFE_PR_NAME/$(date +%s)" mkdir -p "$DEST_DIR" - # 4. Copy the new results - # Assuming your bench tool outputs a file named 'results.json' cp app/benchmark/out/*.json "$DEST_DIR/" - # 5. Commit and Push cd target_bench_repo git add . - git commit -m "Update benchmarks for $SAFE_PR_NAME: ${{ github.sha }}" + git commit -m "Update benchmarks for $SAFE_PR_NAME: ${{ gitea.sha }}" git push origin main - diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index fcbf18b..40f2f06 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -13,46 +13,49 @@ env: CARGO_TARGET_DIR: target jobs: - release: + quality: runs-on: ubuntu-latest container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69 steps: - - name: ๐Ÿ“‘ Checkout Code - uses: actions/checkout@v4 + - name: ๐Ÿ”ง Setup + uses: ./.gitea/actions/setup with: - fetch-depth: 0 token: ${{ secrets.GITEA_TOKEN }} - - name: ๐Ÿ’พ Setup pnpm Cache - uses: actions/cache@v4 - with: - path: ${{ env.PNPM_CACHE_FOLDER }} - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: ๐Ÿฆ€ Cache Cargo - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo- - - - name: ๐Ÿ“ฆ Install Dependencies - run: pnpm install --frozen-lockfile --store-dir ${{ env.PNPM_CACHE_FOLDER }} - - name: ๐Ÿงน Quality Control run: | pnpm lint pnpm format:check pnpm check pnpm build - xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" pnpm test + + test: + runs-on: ubuntu-latest + container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69 + + steps: + - name: ๐Ÿ”ง Setup + uses: ./.gitea/actions/setup + with: + token: ${{ secrets.GITEA_TOKEN }} + + - name: ๐Ÿงช Run Tests + run: xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" pnpm test + + deploy: + runs-on: ubuntu-latest + needs: [quality, test] + container: git.max-richter.dev/max/nodarium-ci:a56e8f445edb6064ae7a7b3b783fb7445f1b4e69 + + steps: + - name: ๐Ÿ”ง Setup + uses: ./.gitea/actions/setup + with: + token: ${{ secrets.GITEA_TOKEN }} + + - name: ๐Ÿ—๏ธ Build Web Assets + run: pnpm build - name: ๐Ÿš€ Create Release Commit if: gitea.ref_type == 'tag' @@ -81,4 +84,3 @@ jobs: SSH_HOST: ${{ vars.SSH_HOST }} SSH_PORT: ${{ vars.SSH_PORT }} SSH_USER: ${{ vars.SSH_USER }} -