Skip to content

Commit 772ac1f

Browse files
author
codegen-bot
committed
Merge branch 'develop' into tawsif/fix-imports
2 parents d377327 + 99ad2ee commit 772ac1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3165
-1330
lines changed

.github/actions/run-ats/ats.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if [ ! -s codecov_ats/tests_to_run.txt ]; then
5050
echo "No tests to run, collecting from default tests"
5151
PYTEST_ARGS="${COLLECT_ARGS} ${DEFAULT_TESTS}"
5252
echo "Using args: ${PYTEST_ARGS}"
53-
TESTS_TO_RUN=$(PYTEST_ARGS=${PYTEST_ARGS} ./.circleci/collect.sh)
53+
TESTS_TO_RUN=$(PYTEST_ARGS=${PYTEST_ARGS} ./.github/actions/run-ats/collect.sh)
5454
echo "${TESTS_TO_RUN}" > codecov_ats/tests_to_run.txt
5555
run_count=1
5656
echo "Added ${TESTS_TO_RUN} as fallback. New run count: $run_count"

.github/actions/run-ats/collect.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
TESTS_TO_RUN=$(uv run --frozen pytest --collect-only ${PYTEST_ARGS} -q --disable-warnings --no-summary --no-header)
3+
TESTS_TO_RUN=$(echo "${TESTS_TO_RUN}" | head -n -2)
4+
echo $TESTS_TO_RUN

.github/workflows/auto-release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,40 @@ jobs:
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737

38+
generate-changelog:
39+
if: ${{ needs.semantic-version.outputs.release-tag }}
40+
needs: semantic-version
41+
name: Generate Changelog
42+
runs-on: ubuntu-latest
43+
environment: auto-release
44+
permissions:
45+
contents: write
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0
50+
token: ${{ secrets.GHA_TOKEN }}
51+
52+
- name: Setup backend
53+
uses: ./.github/actions/setup-environment
54+
55+
- name: Generate changelog
56+
env:
57+
OPEN_AI_TOKEN: ${{ secrets.OPEN_AI_TOKEN }}
58+
run: uv run python src/codegen/gscli/cli.py generate changelog --openai-key ${{ secrets.OPEN_AI_TOKEN }}
59+
60+
- name: Commit changes
61+
run: |
62+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
63+
git config --local user.name "github-actions[bot]"
64+
git add docs/changelog/changelog.mdx
65+
git diff --staged --quiet || git commit -m "update changelog"
66+
67+
- name: Push changes
68+
uses: ad-m/github-push-action@master
69+
with:
70+
branch: ${{ github.ref }}
71+
3872
release:
3973
if: ${{ needs.semantic-version.outputs.release-tag }}
4074
needs: semantic-version

.github/workflows/generate-docs.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Generate Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
permissions:
9+
contents: write # Need write permission to commit changes
10+
11+
jobs:
12+
generate-docs:
13+
environment: auto-release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
token: ${{ secrets.GHA_TOKEN }}
20+
21+
- name: Setup backend
22+
uses: ./.github/actions/setup-environment
23+
24+
- name: Generate API reference
25+
run: uv run python src/codegen/gscli/cli.py generate docs
26+
27+
- name: Commit changes
28+
run: |
29+
git config --local user.email ${{ secrets.DOCS_USER_EMAIL }}
30+
git config --local user.name ${{ secrets.DOCS_USER_NAME }}
31+
git add docs/
32+
git diff --staged --quiet || git commit -m "docs: updated API reference"
33+
34+
- name: Push changes
35+
uses: ad-m/github-push-action@master
36+
with:
37+
branch: ${{ github.ref }}

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
pre-commit:
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 10
15+
env:
16+
REPO_SCOPED_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
1517

1618
steps:
1719
- name: Check out the repo
1820
uses: actions/checkout@v4
1921
with:
2022
fetch-depth: 0
21-
repository: ${{ github.event.pull_request.head.repo.full_name }}
22-
ref: ${{ github.event.pull_request.head.ref }}
23-
token: ${{ secrets.REPO_SCOPED_TOKEN || github.token }}
23+
token: ${{ env.REPO_SCOPED_TOKEN || github.token }}
2424

2525
- name: Setup environment
2626
uses: ./.github/actions/setup-environment
@@ -36,12 +36,9 @@ jobs:
3636

3737
- run: uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha || github.event.before }} --origin ${{ github.event.pull_request.head.sha || github.event.after }}
3838
shell: bash
39-
env:
40-
SKIP: circleci_validate
4139

4240
- uses: stefanzweifel/git-auto-commit-action@v5
43-
# Always commit changes even if pre-commit failed
44-
if: always() && github.event_name == 'pull_request'
41+
if: ${{ always() && env.REPO_SCOPED_TOKEN && github.event_name == 'pull_request' }}
4542
with:
4643
commit_message: "Automated pre-commit update"
4744
push_options: "--no-verify"

.github/workflows/unit-tests.yml renamed to .github/workflows/test.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
name: Unit Tests
1+
name: Tests
22

33
on:
44
push:
55
branches:
66
- "develop"
7-
pull_request:
7+
pull_request_target:
88
types: [ opened, synchronize, reopened, labeled ]
99
branches:
1010
- "develop"
1111
workflow_dispatch:
1212

1313
jobs:
14+
access-check:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions-cool/check-user-permission@v2
18+
with:
19+
require: write
20+
username: ${{ github.triggering_actor }}
21+
error-if-missing: true
22+
1423
unit-tests:
24+
needs: access-check
1525
runs-on: ubuntu-latest-8
26+
environment: testing
1627
steps:
1728
- uses: actions/checkout@v4
1829
with:
1930
fetch-depth: 0
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
2033
- name: Setup environment
2134
uses: ./.github/actions/setup-environment
35+
2236
- name: Run ATS and Tests
2337
uses: ./.github/actions/run-ats
2438
timeout-minutes: 15
@@ -30,9 +44,11 @@ jobs:
3044
codecov_flags: unit-tests
3145

3246
codemod-tests:
47+
needs: access-check
3348
# TODO: re-enable when this check is a develop required check
3449
if: false
3550
runs-on: ubuntu-latest-32
51+
environment: testing
3652
strategy:
3753
matrix:
3854
sync_graph: [ true, false ]
@@ -48,10 +64,15 @@ jobs:
4864
name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}"
4965
steps:
5066
- uses: actions/checkout@v4
67+
with:
68+
ref: ${{ github.event.pull_request.head.sha }}
69+
5170
- name: Setup environment
5271
uses: ./.github/actions/setup-environment
72+
5373
- name: Cache oss-repos
5474
uses: ./.github/actions/setup-oss-repos
75+
5576
- name: Run ATS and Tests
5677
uses: ./.github/actions/run-ats
5778
timeout-minutes: 15
@@ -66,11 +87,15 @@ jobs:
6687
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
6788

6889
parse-tests:
69-
runs-on: ubuntu-latest-32
90+
needs: access-check
7091
if: contains(github.event.pull_request.labels.*.name, 'parse-tests') || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
71-
environment: parse-tests
92+
runs-on: ubuntu-latest-32
93+
environment: testing
7294
steps:
7395
- uses: actions/checkout@v4
96+
with:
97+
ref: ${{ github.event.pull_request.head.sha }}
98+
7499
- name: Setup environment
75100
uses: ./.github/actions/setup-environment
76101

@@ -91,10 +116,12 @@ jobs:
91116
-n auto \
92117
-o junit_suite_name="${{github.job}}" \
93118
tests/integration/codemod/test_parse.py
119+
94120
- uses: ./.github/actions/report
95121
with:
96122
flag: no-flag
97123
codecov_token: ${{ secrets.CODECOV_TOKEN }}
124+
98125
- name: Notify parse tests failure
99126
uses: slackapi/[email protected]
100127
if: failure() && github.event_name == 'push' && false
@@ -132,11 +159,17 @@ jobs:
132159
}
133160
134161
integration-tests:
162+
needs: access-check
135163
runs-on: ubuntu-latest-16
164+
environment: testing
136165
steps:
137166
- uses: actions/checkout@v4
167+
with:
168+
ref: ${{ github.event.pull_request.head.sha }}
169+
138170
- name: Setup environment
139171
uses: ./.github/actions/setup-environment
172+
140173
- name: Test with pytest
141174
timeout-minutes: 5
142175
env:
@@ -147,6 +180,7 @@ jobs:
147180
-n auto \
148181
-o junit_suite_name="${{github.job}}" \
149182
tests/integration/codegen
183+
150184
- uses: ./.github/actions/report
151185
with:
152186
flag: integration-tests

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ uv run pytest tests/unit -n auto
5151
uv run pytest tests/integration/codemod/test_codemods.py -n auto
5252
```
5353

54+
> [!TIP]
55+
>
56+
> - If on Linux the error `OSError: [Errno 24] Too many open files` appears then you might want to increase your _ulimit_
57+
5458
## Pull Request Process
5559

5660
1. Fork the repository and create your branch from `develop`.

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ ARG CODEGEN_BOT_GHE_TOKEN=""
33
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS base_uv
44
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
55
ENV GITHUB_WORKSPACE=/workspace
6-
LABEL com.circleci.preserve-entrypoint=true
76
## Change the working directory to the `codegen-sdk` directory
87
FROM base_uv AS install-tools
98
RUN apt-get update && apt-get install -y build-essential curl git

docs/api-reference/core/Class.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {HorizontalDivider} from '/snippets/HorizontalDivider.mdx';
1111
import {GithubLinkNote} from '/snippets/GithubLinkNote.mdx';
1212
import {Attribute} from '/snippets/Attribute.mdx';
1313

14-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L53-L417" />
14+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L55-L419" />
1515

1616
### Inherits from
1717
[HasBlock](/api-reference/core/HasBlock), [Callable](/api-reference/core/Callable), [Expression](/api-reference/core/Expression), [Usable](/api-reference/core/Usable), [Symbol](/api-reference/core/Symbol), [Editable](/api-reference/core/Editable), [Importable](/api-reference/core/Importable), [HasName](/api-reference/core/HasName)
@@ -147,7 +147,7 @@ import {Attribute} from '/snippets/Attribute.mdx';
147147
<HorizontalDivider />
148148
### <span className="text-primary">add_attribute</span>
149149
Adds an attribute to a class from another class.
150-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L358-L381" />
150+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L360-L383" />
151151

152152
<ParameterWrapper>
153153
<Parameter
@@ -170,7 +170,7 @@ Adds an attribute to a class from another class.
170170

171171
### <span className="text-primary">add_attribute_from_source</span>
172172
Adds an attribute to a class from raw source code, placing it in a specific location
173-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L332-L355" />
173+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L334-L357" />
174174

175175
<ParameterWrapper>
176176
<Parameter
@@ -244,7 +244,7 @@ Insert a keyword in the appropriate place before this symbol if it doesn't alrea
244244

245245
### <span className="text-primary">add_source</span>
246246
Add a block of source code to the bottom of a class definition.
247-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L318-L329" />
247+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L320-L331" />
248248

249249
<ParameterWrapper>
250250
<Parameter
@@ -269,7 +269,7 @@ Find all ancestors of the node of the given type. Does not return itself
269269

270270
### <span className="text-primary">attributes</span>
271271
Retrieves all attributes from this Class including those from its superclasses up to a
272-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L272-L291" />
272+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L274-L293" />
273273

274274
<ParameterWrapper>
275275
<Parameter
@@ -404,7 +404,7 @@ Adds a visual flag comment to the end of this Editable's source text.
404404

405405
### <span className="text-primary">get_attribute</span>
406406
Returns a specific attribute by name.
407-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L294-L311" />
407+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L296-L313" />
408408

409409
<ParameterWrapper>
410410
<Parameter
@@ -421,7 +421,7 @@ Returns a specific attribute by name.
421421

422422
### <span className="text-primary">get_method</span>
423423
Returns a specific method by name from the class or any of its superclasses.
424-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L251-L268" />
424+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L253-L270" />
425425

426426
<ParameterWrapper>
427427
<Parameter
@@ -446,7 +446,7 @@ Returns the name node of the object.
446446

447447
### <span className="text-primary">get_nested_class</span>
448448
Returns a nested class by name from the current class.
449-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L234-L248" />
449+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L236-L250" />
450450

451451
<ParameterWrapper>
452452
<Parameter
@@ -514,7 +514,7 @@ Retrieves a parameter from the callable by its type.
514514

515515
### <span className="text-primary">get_parent_class</span>
516516
Returns the parent class node with the specified name.
517-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L111-L123" />
517+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L113-L125" />
518518

519519
<ParameterWrapper>
520520
<Parameter
@@ -642,7 +642,7 @@ Inserts text before the current symbol node in the Abstract Syntax Tree.
642642

643643
### <span className="text-primary">is_subclass_of</span>
644644
Checks if the class inherits from a specified parent class.
645-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L138-L152" />
645+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L140-L154" />
646646

647647
<ParameterWrapper>
648648
<Parameter
@@ -673,7 +673,7 @@ Check if this node is contained another node of the given class
673673

674674
### <span className="text-primary">methods</span>
675675
Retrieves all methods that exist on this Class, including methods from superclasses, with
676-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L203-L231" />
676+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L205-L233" />
677677

678678
<ParameterWrapper>
679679
<Parameter
@@ -937,7 +937,7 @@ Sets the name of a code element.
937937

938938
### <span className="text-primary">subclasses</span>
939939
Returns all classes which subclass this class.
940-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L156-L167" />
940+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L158-L169" />
941941

942942
<ParameterWrapper>
943943
<Parameter
@@ -954,7 +954,7 @@ Returns all classes which subclass this class.
954954

955955
### <span className="text-primary">superclasses</span>
956956
Returns a list of all classes that this class extends, up to max_depth.
957-
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L77-L93" />
957+
<GithubLinkNote link="https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/class_definition.py#L79-L95" />
958958

959959
<ParameterWrapper>
960960
<Parameter

0 commit comments

Comments
 (0)