forked from Significant-Gravitas/AutoGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up GitHub Workflows (Significant-Gravitas#3059)
* initial cleanup of github workflows * only run pr-label workflow on push to master * move docker ci/release summaries to scripts * add XS label for PR's under 2 lines * draft test job for Docker CI * fix & activate Docker CI test job * add debug step to docker CI * fix Docker CI test container env * Docker CI build matrix * fixup build summaries * fix pipes in summary * optimize Dockerfile for layer caching * more markdown escaping * add gha cache scopes * add Docker CI cache clean workflow
- Loading branch information
Showing
14 changed files
with
500 additions
and
116 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
22 changes: 11 additions & 11 deletions
22
.github/workflows/benchmark.yml → .github/workflows/benchmarks.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
name: benchmark | ||
name: Run Benchmarks | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: benchmark | ||
strategy: | ||
matrix: | ||
python-version: ['3.10', '3.11'] | ||
|
||
env: | ||
python-version: '3.10' | ||
|
||
steps: | ||
- name: Check out repository | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
- name: Set up Python ${{ env.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
python-version: ${{ env.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: benchmark | ||
run: | | ||
python benchmark/benchmark_entrepreneur_gpt_with_undecisive_user.py | ||
env: | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
run: | | ||
python benchmark/benchmark_entrepreneur_gpt_with_undecisive_user.py |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Purge Docker CI cache | ||
|
||
on: | ||
schedule: | ||
- cron: 20 4 * * 1,4 | ||
|
||
env: | ||
BASE_BRANCH: master | ||
IMAGE_NAME: auto-gpt | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
build-type: [release, dev] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- id: build | ||
name: Build image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
build-args: BUILD_TYPE=${{ matrix.build-type }} | ||
load: true # save to docker images | ||
# use GHA cache as read-only | ||
cache-to: type=gha,scope=docker-${{ matrix.build-type }},mode=max | ||
|
||
- name: Generate build report | ||
env: | ||
event_name: ${{ github.event_name }} | ||
event_ref: ${{ github.event.schedule }} | ||
|
||
build_type: ${{ matrix.build-type }} | ||
|
||
prod_branch: stable | ||
dev_branch: master | ||
repository: ${{ github.repository }} | ||
base_branch: ${{ github.ref_name != 'master' && github.ref_name != 'stable' && 'master' || 'stable' }} | ||
|
||
current_ref: ${{ github.ref_name }} | ||
commit_hash: ${{ github.sha }} | ||
source_url: ${{ format('{0}/tree/{1}', github.event.repository.url, github.sha) }} | ||
push_forced_label: | ||
|
||
new_commits_json: ${{ null }} | ||
compare_url_template: ${{ format('/{0}/compare/{{base}}...{{head}}', github.repository) }} | ||
|
||
github_context_json: ${{ toJSON(github) }} | ||
job_env_json: ${{ toJSON(env) }} | ||
vars_json: ${{ toJSON(vars) }} | ||
|
||
run: .github/workflows/scripts/docker-ci-summary.sh >> $GITHUB_STEP_SUMMARY | ||
continue-on-error: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: Docker CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
concurrency: | ||
group: ${{ format('docker-ci-{0}', github.head_ref && format('pr-{0}', github.event.pull_request.number) || github.sha) }} | ||
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
env: | ||
IMAGE_NAME: auto-gpt | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
build-type: [release, dev] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- if: runner.debug | ||
run: | | ||
ls -al | ||
du -hs * | ||
- id: build | ||
name: Build image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
build-args: BUILD_TYPE=${{ matrix.build-type }} | ||
tags: ${{ env.IMAGE_NAME }} | ||
load: true # save to docker images | ||
# cache layers in GitHub Actions cache to speed up builds | ||
cache-from: type=gha,scope=docker-${{ matrix.build-type }} | ||
cache-to: type=gha,scope=docker-${{ matrix.build-type }},mode=max | ||
|
||
- name: Generate build report | ||
env: | ||
event_name: ${{ github.event_name }} | ||
event_ref: ${{ github.event.ref }} | ||
event_ref_type: ${{ github.event.ref}} | ||
|
||
build_type: ${{ matrix.build-type }} | ||
|
||
prod_branch: stable | ||
dev_branch: master | ||
repository: ${{ github.repository }} | ||
base_branch: ${{ github.ref_name != 'master' && github.ref_name != 'stable' && 'master' || 'stable' }} | ||
|
||
current_ref: ${{ github.ref_name }} | ||
commit_hash: ${{ github.event.after }} | ||
source_url: ${{ format('{0}/tree/{1}', github.event.repository.url, github.event.release && github.event.release.tag_name || github.sha) }} | ||
push_forced_label: ${{ github.event.forced && '☢️ forced' || '' }} | ||
|
||
new_commits_json: ${{ toJSON(github.event.commits) }} | ||
compare_url_template: ${{ format('/{0}/compare/{{base}}...{{head}}', github.repository) }} | ||
|
||
github_context_json: ${{ toJSON(github) }} | ||
job_env_json: ${{ toJSON(env) }} | ||
vars_json: ${{ toJSON(vars) }} | ||
|
||
run: .github/workflows/scripts/docker-ci-summary.sh >> $GITHUB_STEP_SUMMARY | ||
continue-on-error: true | ||
|
||
# Docker setup needs fixing before this is going to work: #1843 | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- id: build | ||
name: Build image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
build-args: BUILD_TYPE=dev # include pytest | ||
tags: ${{ env.IMAGE_NAME }} | ||
load: true # save to docker images | ||
# cache layers in GitHub Actions cache to speed up builds | ||
cache-from: type=gha,scope=docker-dev | ||
cache-to: type=gha,scope=docker-dev,mode=max | ||
|
||
- id: test | ||
name: Run tests | ||
env: | ||
CI: true | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
run: | | ||
set +e | ||
test_output=$( | ||
docker run --env CI --env OPENAI_API_KEY --entrypoint python ${{ env.IMAGE_NAME }} -m \ | ||
pytest --cov=autogpt --cov-report term-missing --cov-branch --cov-report xml --cov-report term 2>&1 | ||
) | ||
test_failure=$? | ||
echo "$test_output" | ||
cat << $EOF >> $GITHUB_STEP_SUMMARY | ||
# Tests $([ $test_failure = 0 ] && echo '✅' || echo '❌') | ||
\`\`\` | ||
$test_output | ||
\`\`\` | ||
$EOF |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Docker Release | ||
|
||
on: | ||
release: | ||
types: [ published, edited ] | ||
|
||
workflow_dispatch: | ||
inputs: | ||
no_cache: | ||
type: boolean | ||
description: 'Build from scratch, without using cached layers' | ||
|
||
env: | ||
IMAGE_NAME: auto-gpt | ||
DEPLOY_IMAGE_NAME: ${{ secrets.DOCKER_USER }}/auto-gpt | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
# slashes are not allowed in image tags, but can appear in git branch or tag names | ||
- id: sanitize_tag | ||
name: Sanitize image tag | ||
run: echo tag=${raw_tag//\//-} >> $GITHUB_OUTPUT | ||
env: | ||
raw_tag: ${{ github.ref_name }} | ||
|
||
- id: build | ||
name: Build image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
build-args: BUILD_TYPE=release | ||
load: true # save to docker images | ||
# push: true # TODO: uncomment when this issue is fixed: https://github.com/moby/buildkit/issues/1555 | ||
tags: > | ||
${{ env.IMAGE_NAME }}, | ||
${{ env.DEPLOY_IMAGE_NAME }}:latest, | ||
${{ env.DEPLOY_IMAGE_NAME }}:${{ steps.sanitize_tag.outputs.tag }} | ||
# cache layers in GitHub Actions cache to speed up builds | ||
cache-from: ${{ !inputs.no_cache && 'type=gha' || '' }},scope=docker-release | ||
cache-to: type=gha,scope=docker-release,mode=max | ||
|
||
- name: Push image to Docker Hub | ||
run: docker push --all-tags ${{ env.DEPLOY_IMAGE_NAME }} | ||
|
||
- name: Generate build report | ||
env: | ||
event_name: ${{ github.event_name }} | ||
event_ref: ${{ github.event.ref }} | ||
event_ref_type: ${{ github.event.ref}} | ||
inputs_no_cache: ${{ inputs.no_cache }} | ||
|
||
prod_branch: stable | ||
dev_branch: master | ||
repository: ${{ github.repository }} | ||
base_branch: ${{ github.ref_name != 'master' && github.ref_name != 'stable' && 'master' || 'stable' }} | ||
|
||
ref_type: ${{ github.ref_type }} | ||
current_ref: ${{ github.ref_name }} | ||
commit_hash: ${{ github.sha }} | ||
source_url: ${{ format('{0}/tree/{1}', github.event.repository.url, github.event.release && github.event.release.tag_name || github.sha) }} | ||
|
||
github_context_json: ${{ toJSON(github) }} | ||
job_env_json: ${{ toJSON(env) }} | ||
vars_json: ${{ toJSON(vars) }} | ||
|
||
run: .github/workflows/scripts/docker-release-summary.sh >> $GITHUB_STEP_SUMMARY | ||
continue-on-error: true |
Oops, something went wrong.