diff --git a/.github/workflows/_generate.yml b/.github/workflows/_generate.yml new file mode 100644 index 00000000000..e9aeec6b3a7 --- /dev/null +++ b/.github/workflows/_generate.yml @@ -0,0 +1,45 @@ +--- +name: _generate + +"on": + workflow_call: + inputs: + force: + type: boolean + default: false + dry_run: + type: boolean + default: false + + workflow_dispatch: + inputs: + force: + description: "Regenerate all of the derived data, even if it already exists" + type: boolean + default: false + dry_run: + description: "Dry run: Do not commit to the repo" + type: boolean + default: false + +jobs: + generate-results: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: pip + - name: install dependencies + run: + python -m pip install -r requirements.txt + - name: regenerate + run: + python -m bench_runner.scripts.generate_results ${{ inputs.force == true && '--force' || '' }} + - name: Add to repo + uses: EndBug/add-and-commit@v9 + if: ${{ !inputs.dry_run }} + with: + add: "['results', 'README.md', 'RESULTS.md', 'longitudinal.png', 'profiling/profiling.png', 'profiling/profiling.md']" + message: Benchmarking results for @${{ github.actor }} diff --git a/.github/workflows/_publish.yml b/.github/workflows/_publish.yml new file mode 100644 index 00000000000..d46d1f5b8ca --- /dev/null +++ b/.github/workflows/_publish.yml @@ -0,0 +1,50 @@ +--- +name: _publish + +"on": + workflow_call: + inputs: + force: + type: boolean + default: false + dry_run: + type: boolean + default: false + + workflow_dispatch: + inputs: + force: + description: "Regenerate all of the derived data, even if it already exists" + type: boolean + default: false + dry_run: + description: "Dry run: Do not commit to the repo" + type: boolean + default: false + +jobs: + mirror: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + path: private + ref: main + fetch-depth: 0 + - uses: actions/checkout@v3 + with: + path: public + ref: main + repository: faster-cpython/benchmarking-public + token: ${{ secrets.BENCHMARK_MIRROR }} + - name: Mirror + run: | + cd public + git remote add upstream $PWD/../private + git fetch upstream + git reset --hard upstream/main + - name: Push + if: ${{ !inputs.dry_run }} + run: | + cd public + git push origin main diff --git a/.github/workflows/benchrunner-aws.yml b/.github/workflows/benchrunner-aws.yml new file mode 100644 index 00000000000..f24bde37814 --- /dev/null +++ b/.github/workflows/benchrunner-aws.yml @@ -0,0 +1,32 @@ +name: Deploy benchrunner to AWS + +on: + push: + branches: + - main + workflow_dispatch: {} + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Check out the repository to the runner + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Set Up Terraform + uses: hashicorp/setup-terraform@v2 + + - name: Start EC2 instance Using Terraform Configuration + run: | + cd terraform + terraform init + terraform apply -auto-approve + diff --git a/.gitignore b/.gitignore index d32231d1abc..b702d3fe33b 100644 --- a/.gitignore +++ b/.gitignore @@ -168,3 +168,20 @@ pyembed_includes .cache/ build_cinderx_venv/ CinderX/build/ + +# Ignore Terraform state files, directories, and logs +*.tfstate +*.tfstate.* +*.terraform +*.terraform.* +.terraform/ +terraform.log + +# Ignore sensitive or auto-generated files +*.pem +*.key +*.tfvars +*.tfvars.* + +# Ignore venv directory +venv/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000000..fadb5fcc0f9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/faster-cpython/bench_runner@v0.2.2#egg=bench_runner diff --git a/terraform/init.sh b/terraform/init.sh new file mode 100644 index 00000000000..0bb36a27881 --- /dev/null +++ b/terraform/init.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "This is a test file was created during the instance initialization." > test.txt diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 00000000000..b170d9ce618 --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,94 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.16" + } + } + + required_version = ">= 1.2.0" +} + +provider "aws" { + region = "us-west-2" +} + +resource "aws_vpc" "bench_run" { + cidr_block = "10.0.0.0/16" + enable_dns_hostnames = true + enable_dns_support = true + + tags = { + Name = "bench_run" + } +} + +resource "aws_eip" "bench_run_ip" { + instance = aws_instance.bench_runner.id + vpc = true +} + +resource "aws_internet_gateway" "bench_run_gw" { + vpc_id = aws_vpc.bench_run.id + + tags = { + Name = "bench_run_gw" + } +} + +resource "aws_subnet" "subnet1" { + cidr_block = cidrsubnet(aws_vpc.bench_run.cidr_block, 3, 1) + vpc_id = aws_vpc.bench_run.id + availability_zone = "us-west-2a" +} + +resource "aws_route_table" "bench_run_route_table" { + vpc_id = aws_vpc.bench_run.id + + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.bench_run_gw.id + } + + tags = { + Name = "bench_run_route_table" + } +} + +resource "aws_route_table_association" "subnet_association" { + subnet_id = aws_subnet.subnet1.id + route_table_id = aws_route_table.bench_run_route_table.id +} + +resource "aws_security_group" "ingress_all" { + name = "allow_all_sg" + vpc_id = aws_vpc.bench_run.id + + ingress { + cidr_blocks = ["0.0.0.0/0"] + from_port = 22 + to_port = 22 + protocol = "tcp" + } + + egress { + cidr_blocks = ["0.0.0.0/0"] + from_port = 0 + to_port = 0 + protocol = "-1" + } +} + +resource "aws_instance" "bench_runner" { + ami = "ami-830c94e3" + instance_type = "t2.micro" + key_name = "bench-runner" + vpc_security_group_ids = ["${aws_security_group.ingress_all.id}"] + subnet_id = aws_subnet.subnet1.id + user_data = file("init.sh") + + tags = { + Name = "BenchmarkingEC2Runner" + } +} +