readme: demo image #93
This file contains hidden or 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
| name: Build | |
| on: | |
| push: | |
| pull_request: | |
| release: | |
| types: [created] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| BINARIES: fi-nodes fi-slurm-limits | |
| jobs: | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_tag: ${{ steps.meta.outputs.tags }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/metadata-action@v5 | |
| id: meta | |
| with: | |
| images: ghcr.io/${{ github.repository_owner }}/fi-slurm-rust-builder | |
| tags: type=raw,value=${{ github.ref_name }} | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/build-push-action@v6 | |
| with: | |
| context: .github | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| check: | |
| needs: build-docker | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: > | |
| docker run --rm -v "${{ github.workspace }}:/app" ${{ needs.build-docker.outputs.image_tag }} | |
| sh -c ' | |
| git config --global --add safe.directory $PWD && | |
| python3 -m pip install pre-commit && | |
| pre-commit run --all-files; | |
| ec=$?; | |
| [ $ec -ne 0 ] && cat /root/.cache/pre-commit/pre-commit.log; | |
| exit $ec | |
| ' | |
| - uses: pre-commit-ci/lite-action@v1.1.0 | |
| if: always() | |
| build: | |
| needs: build-docker | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ${{ needs.build-docker.outputs.image_tag }} | |
| outputs: | |
| slurm_version: ${{ steps.get_versions.outputs.slurm_version }} | |
| rust_target: ${{ steps.get_versions.outputs.rust_target }} | |
| # TODO: cargo cache | |
| # - uses: actions/cache@v4 | |
| # with: | |
| # path: | | |
| # ~/.cargo/registry | |
| # ~/.cargo/git | |
| # target | |
| # key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: cargo build --release --verbose --all-features | |
| - run: | | |
| mkdir -p artifacts | |
| cd target/release/ | |
| mv -t ../../artifacts/ ${{ env.BINARIES }} | |
| - name: Get target and Slurm version | |
| id: get_versions | |
| run: | | |
| echo "rust_target=$(cat /etc/rust_target)" >> $GITHUB_OUTPUT | |
| echo "slurm_version=$(cat /etc/slurm_version)" >> $GITHUB_OUTPUT | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: fi-slurm-binaries | |
| path: | | |
| artifacts/* | |
| publish: | |
| needs: [build, check] | |
| environment: publish | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| steps: | |
| - name: Checkout fi-utils | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: flatironinstitute/fi-utils | |
| token: ${{ secrets.FI_UTILS_TOKEN }} | |
| ref: prod | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: fi-slurm-binaries | |
| path: artifacts | |
| - name: Push to fi-utils | |
| run: | | |
| chmod +x artifacts/* | |
| cp -t bin/ artifacts/* | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add bin/ | |
| git commit \ | |
| -m "fi-slurm-utils: release ${{ github.ref_name }}, Slurm ${{ needs.build.outputs.slurm_version }}, ${{ needs.build.outputs.rust_target }}" \ | |
| -m "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ github.ref_name }}" \ | |
| -m "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \ | |
| || echo "No commit" | |
| git push | |
| - name: Upload as release asset | |
| run: | | |
| for f in artifacts/*; do | |
| mv "$f" "${f}-${{ needs.build.outputs.rust_target }}-slurm${{ needs.build.outputs.slurm_version }}"; | |
| done | |
| gh release upload "${{ github.ref_name }}" artifacts/* -R ${{ github.repository }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |