diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..25be0f6 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +FROM rust:1-bookworm + +# Install build and OpenCL headers (compile-time), BLAS/LAPACK, git, curl +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + pkg-config \ + git \ + curl \ + ocl-icd-opencl-dev \ + clinfo \ + libblas-dev \ + liblapack-dev \ + && rm -rf /var/lib/apt/lists/* + +# Set a default workdir used by Dev Containers / Codespaces +WORKDIR /workspaces/ha-ndarray + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..087a6de --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "ha-ndarray", + "build": { + "dockerfile": "Dockerfile" + }, + "remoteUser": "root", + "containerEnv": { + "RUST_BACKTRACE": "1" + }, + "postCreateCommand": "rustup component add clippy rustfmt && cargo fetch", + "customizations": { + "vscode": { + "extensions": [ + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml" + ] + } + } +} diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml new file mode 100644 index 0000000..6fc537d --- /dev/null +++ b/.github/workflows/devcontainer.yml @@ -0,0 +1,35 @@ +name: Dev Container + +on: + pull_request: + push: + branches: [ devcontainer-codespaces ] + +jobs: + build-devcontainer: + name: Build .devcontainer/Dockerfile (${{ matrix.platform }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: [ linux/amd64, linux/arm64 ] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU (emulation for non-native arch) + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build (cache-enabled) + uses: docker/build-push-action@v5 + with: + context: . + file: .devcontainer/Dockerfile + platforms: ${{ matrix.platform }} + push: false + load: true + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/notify-devcontainer.yml b/.github/workflows/notify-devcontainer.yml new file mode 100644 index 0000000..35103a0 --- /dev/null +++ b/.github/workflows/notify-devcontainer.yml @@ -0,0 +1,52 @@ +name: Notify Devcontainer Status + +on: + workflow_run: + workflows: ["Dev Container"] + types: [completed] + +jobs: + notify: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + actions: read + steps: + - name: Comment PR with results + uses: actions/github-script@v7 + with: + script: | + const run = context.payload.workflow_run; + const { data } = await github.rest.actions.listJobsForWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: run.id, + per_page: 100, + }); + + const lines = (data.jobs || []).map(j => `- ${j.name}: ${j.conclusion}`); + const body = [ + `Dev Container workflow completed: ${run.conclusion}`, + ``, + `Jobs:`, + ...lines, + ``, + `Run: ${run.html_url}`, + ].join('\n'); + + const prs = run.pull_requests || []; + if (prs.length === 0) { + core.info('No associated PRs to notify.'); + return; + } + + for (const pr of prs) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body, + }); + } +