Skip to content

[Infra] Get rid of the Terraform/AWS, fix missing arm64 and docker image artifacts #2160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 7 additions & 68 deletions .github/workflows/release-artifacts.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build release binaries
name: Build release artifacts
on:
release:
types: [published]
Expand All @@ -13,81 +13,20 @@ permissions:
packages: write

jobs:
start-runner:
name: Start EC2 runner
runs-on: ubuntu-latest
outputs:
instance_id: ${{ steps.invoke-start.outputs.INSTANCE_ID }}
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.EC2_ROLE }}
aws-region: ${{ vars.EC2_REGION }}
- name: Start EC2 instance
id: invoke-start
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
EC2_START: ${{ secrets.EC2_START }}
run: |
RUNNER_TOKEN=$(gh api -X POST -q '.token' /repos/${{ github.repository }}/actions/runners/registration-token)
aws lambda invoke \
--cli-binary-format raw-in-base64-out \
--function-name "$EC2_START" \
--payload '{"ref_name":"${{ github.ref_name }}","runner_token":"'"${RUNNER_TOKEN}"'"}' \
response.json
INSTANCE_ID=$(jq -r '.body.instance_id' < response.json)
echo "INSTANCE_ID=${INSTANCE_ID}" >>"$GITHUB_OUTPUT"
echo "Got EC2 instance ${INSTANCE_ID}"
echo 'Waiting for GitHub runner to start'
while [[ -z "$(gh api /repos/${{ github.repository }}/actions/runners | jq '.runners[] | select(.name == "ec2-spot")')" ]]; do
sleep 60
done
echo 'Done 🎉'

stop-runner:
name: Stop EC2 runner
runs-on: ubuntu-latest
# Ensure that `stop-runner` will always stop the EC2 instance, even if other jobs failed or were canceled
if: ${{ always() }}
needs:
- start-runner
- docker-multiplatform-image
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.EC2_ROLE }}
aws-region: ${{ vars.EC2_REGION }}
- name: Delete GitHub Runner
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_FOR_UPDATES }}
run: |
RUNNER_ID=$(gh api /repos/${{ github.repository }}/actions/runners | jq '.runners[] | select(.name == "ec2-spot") | .id')
if [[ -n "${RUNNER_ID}" ]]; then
gh api -X DELETE /repos/${{ github.repository }}/actions/runners/${RUNNER_ID}
fi
- name: Lambda Invoke Stop
env:
EC2_STOP: ${{ secrets.EC2_STOP }}
run: |
aws lambda invoke \
--cli-binary-format raw-in-base64-out \
--function-name "$EC2_STOP" \
--payload '{"instance_id":"${{ needs.start-runner.outputs.instance_id }}"}' \
response.json
cat response.json

release-artifacts:
name: "Build Nickel binary and Docker image"
strategy:
matrix:
os:
- runs-on: ubuntu-latest
architecture: x86_64
- runs-on: [EC2, ARM64, Linux]
# We don't use the latest version of Ubuntu on the ARM runner because
# rustc is likely to crash, see
# https://github.com/rust-lang/rust/issues/135867. Do not update until
# #135867 is fixed.
- runs-on: ubuntu-22.04-arm
architecture: arm64
runs-on: ${{ matrix.os.runs-on }}
needs:
- start-runner
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -149,7 +88,7 @@ jobs:
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.release_tag }}
run: |
docker buildx imagetools create -t ghcr.io/tweag/nickel:$RELEASE_TAG ghcr.io/tweag/nickel:$RELEASE_TAG-x86_64 ghcr.io/tweag/nickel:$RELEASE_TAG-arm64
docker buildx imagetools inspect ghcr.io/tweag/nickel:$RELEASE_TAG
docker buildx imagetools inspect ghcr.io/tweag/nickel:$RELEASE_TAG

release-artifacts-macos:
name: "Build MacOS Nickel binaries"
Expand Down
3 changes: 0 additions & 3 deletions infra/.gitignore

This file was deleted.

61 changes: 0 additions & 61 deletions infra/README.md

This file was deleted.

49 changes: 0 additions & 49 deletions infra/github-oidc.ncl

This file was deleted.

62 changes: 0 additions & 62 deletions infra/github-runner.nix

This file was deleted.

37 changes: 0 additions & 37 deletions infra/github-variables.ncl

This file was deleted.

Loading
Loading