Skip to content
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

Github Action: Add format.yml workflow #30604

Merged
merged 24 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e8702fc
Fix format issues
bnchrch Sep 20, 2023
beb4ca0
[Skip CI] Add new format workflow file
bnchrch Sep 20, 2023
7211d55
Fix airbyte-ci connector format
bnchrch Sep 20, 2023
646950f
Format s3
bnchrch Sep 20, 2023
0db6392
Revert "Format s3"
bnchrch Sep 21, 2023
1178609
Revert "Fix format issues"
bnchrch Sep 21, 2023
850c4c9
Merge remote-tracking branch 'origin/master' into bnchrch/fix/broken-…
bnchrch Sep 21, 2023
1ad03ea
Automated Commit - Formatting Changes
bnchrch Sep 21, 2023
dac8968
Ensure ci is set
bnchrch Sep 21, 2023
ae144b6
Fix scaffold
bnchrch Sep 21, 2023
b89a745
Revert "Automated Commit - Formatting Changes"
bnchrch Sep 21, 2023
94f4b6d
Merge remote-tracking branch 'origin/master' into bnchrch/fix/broken-…
bnchrch Sep 21, 2023
8a5c1bc
Automated Commit - Formatting Changes
bnchrch Sep 21, 2023
00c83ea
Revert "Automated Commit - Formatting Changes"
bnchrch Sep 21, 2023
b5a1640
Merge remote-tracking branch 'origin/master' into bnchrch/fix/broken-…
bnchrch Sep 21, 2023
fd062d6
Automated Commit - Formatting Changes
bnchrch Sep 21, 2023
45fa547
Revert "Automated Commit - Formatting Changes"
bnchrch Sep 21, 2023
fb4cb88
Upgrade to use pat
bnchrch Sep 21, 2023
07a6ebd
Merge remote-tracking branch 'origin/master' into bnchrch/fix/broken-…
bnchrch Sep 21, 2023
c3cf3e0
Fix pat
bnchrch Sep 21, 2023
ff32b30
Automated Commit - Formatting Changes
bnchrch Sep 21, 2023
6ced6fd
Automated Commit - Format and Process Resources Changes
octavia-approvington Sep 21, 2023
f5bac8b
Remove silly commit
bnchrch Sep 21, 2023
a3b189f
Automated Commit - Formatting Changes
bnchrch Sep 21, 2023
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
26 changes: 13 additions & 13 deletions .devcontainer/destination-duckdb/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
"customizations": {
"vscode": {
"extensions": [
// Python extensions:
"charliermarsh.ruff",
"matangover.mypy",
"ms-python.black",
"ms-python.python",
"ms-python.vscode-pylance",
// Python extensions:
"charliermarsh.ruff",
"matangover.mypy",
"ms-python.black",
"ms-python.python",
"ms-python.vscode-pylance",

// Toml support
"tamasfe.even-better-toml",

// Yaml and JSON Schema support:
"redhat.vscode-yaml",
// Toml support
"tamasfe.even-better-toml",

// Contributing:
"GitHub.vscode-pull-request-github"
// Yaml and JSON Schema support:
"redhat.vscode-yaml",

// Contributing:
"GitHub.vscode-pull-request-github"
],
"settings": {
"extensions.ignoreRecommendations": true,
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Format Code (Python + Java)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
jobs:
format-and-commit:
runs-on: ubuntu-latest
name: "Apply All Formatting Rules"
timeout-minutes: 20
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"

- uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Set up CI Gradle Properties
run: |
mkdir -p ~/.gradle/
cat > ~/.gradle/gradle.properties <<EOF
org.gradle.jvmargs=-Xmx8g -Xss4m \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
org.gradle.workers.max=8
org.gradle.vfs.watch=false
EOF

- name: Format
uses: Wandalen/[email protected]
with:
command: ./gradlew format --scan --info --stacktrace
attempt_limit: 3
attempt_delay: 5000 # in ms

# This is helpful in the case that we change a previously committed generated file to be ignored by git.
- name: Remove any files that have been gitignored
run: git ls-files -i -c --exclude-from=.gitignore | xargs -r git rm --cached

- name: Commit Formatting Changes (PR)
uses: stefanzweifel/git-auto-commit-action@v4
# do not commit if master branch
if: github.ref != 'refs/heads/master'
with:
commit_message: Automated Commit - Formatting Changes
commit_user_name: Octavia Squidington III
commit_user_email: [email protected]

- name: "Fail on Formatting Changes (Master)"
if: github.ref == 'refs/heads/master'
run: git --no-pager diff && test -z "$(git --no-pager diff)"

75 changes: 2 additions & 73 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,71 +89,10 @@ jobs:
# - run: |
# echo '${{ toJSON(needs) }}'

format:
needs: changes
runs-on: ubuntu-latest
# Because scheduled builds on master require us to skip the changes job. Use always() to force this to run on master.
if: needs.changes.outputs.any_change == 'true' || (always() && github.ref == 'refs/heads/master')
name: "Apply All Formatting Rules"
timeout-minutes: 20
steps:
- name: Checkout Airbyte
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

# Caching causes occasional failure of the checkPython step which can't find the venv
# - name: Cache Build Artifacts
# uses: ./.github/actions/cache-build-artifacts
# with:
# cache-key: ${{ secrets.CACHE_VERSION }}-format

- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"

- uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Set up CI Gradle Properties
run: |
mkdir -p ~/.gradle/
cat > ~/.gradle/gradle.properties <<EOF
org.gradle.jvmargs=-Xmx8g -Xss4m \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
org.gradle.workers.max=8
org.gradle.vfs.watch=false
EOF

- name: Format
uses: Wandalen/[email protected]
with:
command: ./gradlew format --scan --info --stacktrace
attempt_limit: 3
attempt_delay: 5000 # in ms

# This is helpful in the case that we change a previously committed generated file to be ignored by git.
- name: Remove any files that have been gitignored
run: git ls-files -i -c --exclude-from=.gitignore | xargs -r git rm --cached

# - name: Commit Formatting Changes
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: Automated Commit - Formatting Changes
# commit_user_name: Octavia Squidington III
# commit_user_email: [email protected]

## BUILDS
octavia-cli-build:
needs:
- changes
- format
runs-on: ubuntu-latest
# Because scheduled builds on master require us to skip the changes job. Use always() to force this to run on master.
if: needs.changes.outputs.cli == 'true' || needs.changes.outputs.build == 'true' || (always() && github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -212,7 +151,6 @@ jobs:
python-cdk-build:
needs:
- changes
- format
runs-on: ubuntu-latest
# Because scheduled builds on master require us to skip the changes job. Use always() to force this to run on master.
if: needs.changes.outputs.python_cdk == 'true' || needs.changes.outputs.build == 'true' || (always() && github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -267,7 +205,6 @@ jobs:
java-cdk-build:
needs:
- changes
- format
runs-on: ubuntu-latest
# Because scheduled builds on master require us to skip the changes job. Use always() to force this to run on master.
if: needs.changes.outputs.java_cdk == 'true' || needs.changes.outputs.build == 'true' || (always() && github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -314,7 +251,6 @@ jobs:
name: "Connectors Base: Start Build EC2 Runner"
needs:
- changes
- format
# Because scheduled builds on master require us to skip the changes job. Use always() to force this to run on master.
if: |
needs.changes.outputs.build == 'true' || needs.changes.outputs.connectors_base == 'true' || needs.changes.outputs.db == 'true' || (always() && github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -403,17 +339,10 @@ jobs:
attempt_limit: 3
attempt_delay: 5000 # in ms

# Verify that the only committed file changes will be those made by the build, formatter or processResources
- name: Ensure no file change from code formatting
# Verify that the the scaffold generation did not change any files. Meaning that the generated files are up to date.
- name: Ensure no file change from scaffold generation
run: git --no-pager diff && test -z "$(git --no-pager diff)"

- name: Format
uses: Wandalen/[email protected]
with:
command: SUB_BUILD=CONNECTORS_BASE ./gradlew format --scan --info --stacktrace
attempt_limit: 3
attempt_delay: 5000 # in ms

- name: Build
uses: Wandalen/[email protected]
with:
Expand Down
Loading