Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions .github/workflows/autoupdate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Autoupdate PR
on:
push:
branches:
- combined-sdk

jobs:
update_pull_requests:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.DISPATCH_ACCESS_TOKEN }}

- name: Set up Git
run: |
git config --global user.name 'box-sdk-build'
git config --global user.email 'box-sdk-build@box.com'

- name: Fetch all branches and tags
run: git fetch --prune --unshallow

- name: Auto update pull requests
run: |
PR_LIST=$(curl -s -H "Authorization: Bearer ${{ secrets.DISPATCH_ACCESS_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" | jq -r '.[] | .head.ref')
for pr_branch in $PR_LIST; do
git checkout "$pr_branch"
if git merge origin/combined-sdk; then
git push
else
# Conflict occurred, resolve by keeping our changes
git checkout --ours .
git add .
git commit -m "Auto resolve conflict by keeping our changes"
git push
fi
done
Comment on lines +9 to +39

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 8 months ago

To fix the issue, add a permissions block to the workflow (either at the root or at the job level). This block limits the GITHUB_TOKEN permissions during the run, following least privilege. Based on the workflow's actions, it needs to be able to "read" repository contents and "write" to pull requests (since it updates PR branches and could interact with them or post commits). This matches the recommended minimal permissions for automation updating pull requests. You should add:

permissions:
  contents: read
  pull-requests: write

immediately after the workflow name: and before on:, which will apply to the whole workflow. No further code changes are needed, as this only modifies the workflow permissions.


Suggested changeset 1
.github/workflows/autoupdate-pr.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/autoupdate-pr.yml b/.github/workflows/autoupdate-pr.yml
--- a/.github/workflows/autoupdate-pr.yml
+++ b/.github/workflows/autoupdate-pr.yml
@@ -1,4 +1,7 @@
 name: Autoupdate PR
+permissions:
+  contents: read
+  pull-requests: write
 on:
   push:
     branches:
EOF
@@ -1,4 +1,7 @@
name: Autoupdate PR
permissions:
contents: read
pull-requests: write
on:
push:
branches:
Copilot is powered by AI and may make mistakes. Always verify output.
34 changes: 34 additions & 0 deletions .github/workflows/integration-tests-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Integration tests sdk
on:
pull_request:
branches:
- combined-sdk
jobs:
core:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- name: All Tests
if: startsWith(github.head_ref, 'codegen-release')
env:
JAVA_COLLABORATOR_ID: ${{ secrets.JAVA_COLLABORATOR_ID }}
JAVA_COLLABORATOR: ${{ secrets.JAVA_COLLABORATOR }}
JAVA_ENTERPRISE_ID: ${{ secrets.JAVA_ENTERPRISE_ID }}
JAVA_JWT_CONFIG: ${{ secrets.JAVA_JWT_CONFIG }}
JAVA_USER_ID: ${{ secrets.JAVA_USER_ID }}
run: ./gradlew integrationTest --stacktrace
- name: Smoke Tests
if: "!startsWith(github.head_ref, 'codegen-release')"
env:
JAVA_COLLABORATOR_ID: ${{ secrets.JAVA_COLLABORATOR_ID }}
JAVA_COLLABORATOR: ${{ secrets.JAVA_COLLABORATOR }}
JAVA_ENTERPRISE_ID: ${{ secrets.JAVA_ENTERPRISE_ID }}
JAVA_JWT_CONFIG: ${{ secrets.JAVA_JWT_CONFIG }}
JAVA_USER_ID: ${{ secrets.JAVA_USER_ID }}
run: ./gradlew smokeTest --stacktrace
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: Build and Test daily (sdk-gen)
name: Integration tests sdkgen
on:
schedule:
- cron: "20 1 * * 1-5"
pull_request:
branches:
- combined-sdk
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
distribution: ["zulu", "temurin"]
java: ["8", "17"]
distribution: ['zulu', 'temurin']
java: ['8', '17']
name: Java ${{ matrix.java }} (${{ matrix.distribution }})
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: sdk-gen
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: "gradle"
cache: 'gradle'
- name: All Tests
if: startsWith(github.head_ref, 'codegen-release')
env:
JWT_CONFIG_BASE_64: ${{ secrets.JWT_CONFIG_BASE_64 }}
ADMIN_USER_ID: ${{ secrets.ADMIN_USER_ID }}
Expand All @@ -40,28 +40,13 @@ jobs:
SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }}
SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }}
SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }}
run: ./gradlew check --stacktrace
- name: Coverage
run: ./gradlew integrationTestGen --stacktrace
- name: Smoke Tests
if: "!startsWith(github.head_ref, 'codegen-release')"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew jacocoTestReport coverallsJacoco
notify:
name: Send Slack Notification
runs-on: ubuntu-latest
needs: [build-and-test]
if: always()
steps:
- name: Send Slack Notification
env:
SLACK_WEBHOOK_TEST_NOTIFICATION_URL: ${{ secrets.SLACK_WEBHOOK_TEST_NOTIFICATION_URL }}
BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
if [ "${{ needs.build-and-test.result }}" != "success" ]; then
STATUS="Failure ❌"
else
STATUS="Success ✅"
fi

curl -X POST -H "Content-Type: application/json" \
--data "{\"text\":\"<${BUILD_URL}|Daily Tests Job> in *${GITHUB_REPOSITORY}* finished with status: ${STATUS}\"}" \
"$SLACK_WEBHOOK_TEST_NOTIFICATION_URL"
JWT_CONFIG_BASE_64: ${{ secrets.JWT_CONFIG_BASE_64 }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
USER_ID: ${{ secrets.USER_ID }}
ENTERPRISE_ID: ${{ secrets.ENTERPRISE_ID }}
run: ./gradlew smokeTestGen --stacktrace
29 changes: 0 additions & 29 deletions .github/workflows/integration-tests.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/releases.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- opened
- edited
- synchronize
branches:
- combined-sdk

jobs:
main:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/spell-check-lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: spell-check-lint
on:
pull_request_target:
types: [ opened, synchronize, edited ]
types: [opened, synchronize, edited]
branches:
- main
- combined-sdk
jobs:
spellcheck-request-title:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: build-main
name: Unit tests and Coverage
on:
pull_request:
types: [ opened, synchronize ]
push:
branches:
- main
- combined-sdk
jobs:
build-and-test:
runs-on: ubuntu-latest
Expand All @@ -24,7 +24,9 @@ jobs:
cache: 'gradle'
- name: Build and test
run: ./gradlew check --stacktrace
- name: Coverage
- name: Generate JaCoCo report
run: ./gradlew jacocoTestReport --stacktrace
- name: Upload coverage to Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew jacocoTestReport coverallsJacoco
run: ./gradlew coverallsJacoco --stacktrace
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ The most important change this release includes is the replacement of the HTTP l
* `BoxEvent.Type` is replaced with `EventType`
* Removing deprecated methods from `BoxFile`, `BoxFileVersionRetention`, `BoxFolder`, `BoxGroup`, `BoxGroupMembership`,`BoxItem`, `BoxRetentionPolicy`, `BoxTask`, `BoxUser`, `BoxWebLink`, `EventLog`, `Metadata` and `MetadataTemplate`.

Migration details can be found [here](doc/upgrades/3.x.x%20to%204.x.x.md).
Migration details can be found [here](migration-guides/3.x.x%20to%204.x.x.md).

### New Features and Enhancements:

Expand Down
Loading