Skip to content

Commit b8c5c15

Browse files
authored
Restore old workflows (#162)
- [x] Setup ATS - [x] Setup integration testing # Future PRs: - [ ] Get pypi/cibuildwheel working - [ ] Get doctests back up - [ ] Get auto-commit workflow triggers working - [ ] Add OSS parse tests - [ ] Get slack alerts working
1 parent 6d133cb commit b8c5c15

File tree

16 files changed

+419
-99
lines changed

16 files changed

+419
-99
lines changed

.circleci/config.yml

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,6 @@ commands:
6666
paths:
6767
- $GITHUB_WORKSPACE
6868
key: repos-<<parameters.extra_repos>>
69-
fetch-verified-codemods:
70-
steps:
71-
- run:
72-
command: |
73-
uv run --frozen python -m tests.shared.codemod.commands fetch-verified-codemods --cli-api-key ${PROD_CLI_API_KEY}
74-
cache-verified-codemod-repos:
75-
steps:
76-
- restore_cache:
77-
keys:
78-
- v1-verified-codemod-repos-{{ checksum "tests/integration/verified_codemods/codemod_data/repo_commits.json" }}-{{.Environment.CIRCLE_NODE_INDEX}}-{{.Environment.CIRCLE_NODE_TOTAL}}
79-
- run:
80-
command: |
81-
uv run --frozen python -m tests.shared.codemod.commands clone-repos --verified-codemod-repos --token ${CODEGEN_BOT_GHE_TOKEN}
82-
- save_cache:
83-
paths:
84-
- $GITHUB_WORKSPACE
85-
key: v1-verified-codemod-repos-{{ checksum "tests/integration/verified_codemods/codemod_data/repo_commits.json" }}-{{.Environment.CIRCLE_NODE_INDEX}}-{{.Environment.CIRCLE_NODE_TOTAL}}
8669
build-wheels:
8770
steps:
8871
- install-uv
@@ -192,54 +175,6 @@ commands:
192175
# Define a job to be invoked later in a workflow.
193176
# See: https://circleci.com/docs/jobs-steps/#jobs-overview & https://circleci.com/docs/configuration-reference/#jobs
194177
jobs:
195-
unit-tests:
196-
parallelism: 8
197-
executor: default_image
198-
resource_class: "xlarge"
199-
steps:
200-
- setup-uv
201-
- node/install:
202-
use-nvm-cache: true
203-
- run_ats:
204-
default_tests: "tests/unit"
205-
collect_args: --timeout 50
206-
integration-tests:
207-
executor: default_image
208-
resource_class: "large"
209-
steps:
210-
- setup-uv
211-
- run:
212-
command: |
213-
uv run --frozen pytest -o junit_suite_name="${CIRCLE_JOB}" -n auto tests/integration/codegen
214-
- upload-tests
215-
doctests:
216-
executor: default_image
217-
steps:
218-
- setup-uv
219-
- run:
220-
command: |
221-
uv run --frozen pytest -o junit_suite_name="${CIRCLE_JOB}" -n auto docs
222-
- upload-tests
223-
codemod-tests:
224-
parallelism: 8
225-
executor: default_vm
226-
resource_class: "2xlarge+"
227-
steps:
228-
- install-uv
229-
- setup-uv
230-
- fetch-verified-codemods
231-
- cache-verified-codemod-repos
232-
- run_ats:
233-
default_tests: "tests/integration/codemod/test_verified_codemods.py"
234-
codecov_flags: "smart-tests-codemod"
235-
collect_args: --cli-api-key ${PROD_CLI_API_KEY} --token ${CODEGEN_BOT_GHE_TOKEN}
236-
ats_collect_args: --cli-api-key=${PROD_CLI_API_KEY},--token=${CODEGEN_BOT_GHE_TOKEN},
237-
split_tests: false
238-
- slack/notify:
239-
event: fail
240-
branch_pattern: "develop"
241-
channel: "alerts-codemod-tests"
242-
template: basic_fail_1
243178
oss-codemod-tests:
244179
parameters:
245180
sync_graph:
@@ -372,10 +307,6 @@ jobs:
372307
channel: "release"
373308
template: success_tagged_deploy_1
374309
workflows:
375-
pr_checks:
376-
jobs:
377-
- unit-tests
378-
- integration-tests
379310
publish-packages:
380311
jobs:
381312
- linux-wheels:

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
**/expected_diff.txt filter=lfs diff=lfs merge=lfs -text
21
tests/integration/codemod/repos/extra/*.json filter=lfs diff=lfs merge=lfs -text
3-
**/expected_diff.patch filter=lfs diff=lfs merge=lfs -text
2+
**/test_codegen/expected_diff.patch filter=lfs diff=lfs merge=lfs -text
3+
**/test_codegen/expected_diff.patch.skip filter=lfs diff=lfs merge=lfs -text
44
tests/integration/codemod/repos/repos.json filter=lfs diff=lfs merge=lfs -text
55
tests/integration/verified_codemods/** filter=lfs diff=lfs merge=lfs -text
66
.github/disallowed-words.txt filter=lfs diff=lfs merge=lfs -text

.github/actions/report/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: report
2+
description: "Publish Test Reports"
3+
inputs:
4+
flag:
5+
required: true
6+
description: "Relevant codecov flag"
7+
codecov_token:
8+
required: true
9+
description: "Codecov token"
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Upload test results to Codecov
14+
if: ${{ !cancelled() }}
15+
uses: codecov/test-results-action@v1
16+
with:
17+
token: ${{ inputs.codecov_token }}
18+
files: build/test-results/test/TEST.xml
19+
- name: Upload coverage reports to Codecov
20+
if: (success() || failure()) # always upload coverage reports even if the tests fail
21+
continue-on-error: true
22+
uses: codecov/[email protected]
23+
with:
24+
token: ${{ inputs.codecov_token }}
25+
files: coverage.xml
26+
flags: ${{ inputs.flag }}
27+
plugins: pycoverage,compress-pycoverage

.github/actions/run_ats/action.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 'Run ATS'
2+
description: 'Run Automated Test Selection to determine which tests to run'
3+
4+
inputs:
5+
default_tests:
6+
description: 'Default test path to run'
7+
required: true
8+
codecov_static_token:
9+
description: 'Codecov static token'
10+
required: true
11+
codecov_token:
12+
description: 'Codecov token'
13+
required: true
14+
collect_args:
15+
description: 'Additional arguments for test collection'
16+
required: false
17+
default: ''
18+
ats_collect_args:
19+
description: 'Additional arguments for ATS collection'
20+
required: false
21+
default: ''
22+
codecov_flags:
23+
description: 'Flags for codecov upload'
24+
required: false
25+
default: 'smart-tests'
26+
27+
runs:
28+
using: "composite"
29+
steps:
30+
- name: Run ATS
31+
shell: bash
32+
env:
33+
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
34+
DEFAULT_TESTS: ${{ inputs.default_tests }}
35+
CODECOV_STATIC_TOKEN: ${{ inputs.codecov_static_token }}
36+
CODECOV_TOKEN: ${{ inputs.codecov_token }}
37+
COLLECT_ARGS: ${{ inputs.collect_args }}
38+
ATS_COLLECT_ARGS: ${{ inputs.ats_collect_args }}
39+
run: |
40+
uv run codecovcli create-commit -t ${{ inputs.codecov_token }}
41+
uv run codecovcli create-report -t ${{ inputs.codecov_token }}
42+
bash ./.circleci/ats.sh
43+
44+
- name: Run tests
45+
shell: bash
46+
run: |
47+
echo "pwd: $(pwd)" # FIXME: for debugging
48+
TESTS_TO_RUN=$(cat codecov_ats/tests_to_run.txt)
49+
echo $TESTS_TO_RUN | xargs uv run pytest --cov \
50+
-o junit_suite_name="${{ github.job }}" \
51+
-n auto \
52+
-vv \
53+
--cov \
54+
--cov-append \
55+
--cov-report=xml \
56+
${{ inputs.collect_args }}
57+
58+
- uses: ./.github/actions/report
59+
with:
60+
flag: ${{ inputs.codecov_flags }}
61+
codecov_token: ${{ inputs.codecov_token }}

.github/actions/setup-backend/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
enable-cache: true
2222
prune-cache: false
2323
python-version: ${{ inputs.python-version }}
24-
version: '0.5.20'
24+
version: '0.5.24'
2525
cache-suffix: ${{inputs.python-version}}
2626
- name: Install dependencies
2727
shell: bash
@@ -31,6 +31,7 @@ runs:
3131
shell: bash
3232
run: |
3333
uv tool install codecov-cli --python 3.10
34+
uv tool update-shell
3435
# - name: Configure AWS Credentials
3536
# if: env.skip == '1'
3637
# uses: aws-actions/configure-aws-credentials@v2
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
2+
name: "Setup OSS repos"
3+
description: "Setup OSS repos"
4+
# TODO: add size filter
5+
runs:
6+
using: "composite"
7+
steps:
8+
- name: Cache oss-repos
9+
id: cache-oss-repos
10+
uses: actions/cache@v4
11+
with:
12+
path: oss_repos
13+
key: ${{ runner.os }}-repo-cache-2-${{hashFiles('codegen-backend/codegen_tests/graph_sitter/codemod/repos/open_source/*.json')}}
14+
- name: Populate oss-repos if the cache is empty
15+
if: steps.cache-oss-repos.outputs.cache-hit != 'true'
16+
shell: bash
17+
run: |
18+
uv run --frozen python -m tests.shared.codemod.commands clone-repos --clean-cache
19+
env:
20+
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
21+
- name: Verify cache contents
22+
shell: bash
23+
run: ls -la $GITHUB_WORKSPACE/oss_repos/

.github/codecov.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ flag_management:
5555
statuses:
5656
- type: 'project'
5757
- type: 'patch'
58+
- name: smart-tests-integration-tests
59+
carryforward: true
60+
carryforward_mode: 'labels'
61+
statuses:
62+
- type: 'project'
63+
- type: 'patch'
5864
comment:
5965
layout: "condensed_header, condensed_files"
6066
hide_project_coverage: true

.github/workflows/mypy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Mypy Checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "develop"
7+
8+
concurrency:
9+
group: ${{ github.workflow_ref }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
mypy:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 20
16+
17+
steps:
18+
- name: Checkout Code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup backend
24+
uses: ./.github/actions/setup-backend
25+
26+
- name: Get changed files
27+
id: changed-files
28+
uses: tj-actions/[email protected]
29+
30+
- name: Filter Python files
31+
id: filter-python
32+
run: |
33+
python_files=()
34+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
35+
if [[ $file == *.py ]]; then
36+
python_files+=("${file}")
37+
fi
38+
done
39+
echo "python_files=${python_files[*]}" >> $GITHUB_ENV
40+
41+
- name: Add MyPy annotator
42+
uses: pr-annotators/[email protected]
43+
44+
- name: Run mypy
45+
if: ${{ env.python_files != '' }}
46+
run: |
47+
echo "Running mypy on changed files: ${{ env.python_files }}"
48+
uv run mypy --no-pretty --show-absolute-path ${{ env.python_files }}

.github/workflows/pre-commit.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches:
66
- "develop"
7+
push:
8+
branches:
9+
- "develop"
710

811
jobs:
912
pre-commit:
@@ -23,26 +26,23 @@ jobs:
2326
repository: ${{ github.event.pull_request.head.repo.full_name }}
2427
ref: ${{ github.event.pull_request.head.ref }}
2528
token: ${{ secrets.REPO_SCOPED_TOKEN }}
26-
2729
- name: Setup backend
2830
uses: ./.github/actions/setup-backend
29-
3031
- name: Setup-pre-commit
3132
run: uv tool install pre-commit --with pre-commit-uv --force-reinstall
3233

3334
- uses: actions/cache@v4
3435
with:
3536
path: ~/.cache/pre-commit
3637
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
37-
38-
- run: uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
38+
restore-keys: pre-commit
39+
- run: uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{github.event.pull_request.head.sha }}
3940
shell: bash
4041
env:
41-
SKIP: disallowed-words-check
42+
SKIP: disallowed-words-check,circleci_validate
4243

43-
# TODO: add back in
44-
# - uses: stefanzweifel/git-auto-commit-action@v5
45-
# # Always commit changes even if pre-commit failed
46-
# if: always()
47-
# with:
48-
# commit_message: "Automated pre-commit update"
44+
- uses: stefanzweifel/git-auto-commit-action@v5
45+
# Always commit changes even if pre-commit failed
46+
if: always()
47+
with:
48+
commit_message: "Automated pre-commit update"

0 commit comments

Comments
 (0)