Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
54 changes: 54 additions & 0 deletions .github/workflows/ci_uploads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: IDE File Uploads

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
upload-file:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check for changes in uploads folder
id: check_changes
uses: actions/github-script@v6
with:
script: |
const changedFiles = await github.paginate(
github.rest.repos.compareCommits,
{
owner: context.repo.owner,
repo: context.repo.repo,
base: context.payload.before,
head: context.sha,
}
);

const hasChanges = changedFiles.some(file => file.filename.startsWith('internal/com.espressif.idf.uploads/'));
core.setOutput('changed', hasChanges);

- name: Upload file to S3
if: steps.check_changes.outputs.changed == 'true'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
run: |
FILE="./internal/com.espressif.idf.uploads/cmakeed/CMakeEd-1.24.1.zip"
FILE_NAME=$(basename "$FILE")
BUCKET_NAME="dl.espressif.com"
REMOTE_PATH="dl/cmakeed/updates/"

if [ -f "$FILE" ]; then
echo "Uploading $FILE_NAME to S3..."
aws s3 cp "$FILE" "s3://$BUCKET_NAME/$REMOTE_PATH$FILE_NAME" --acl public-read
else
echo "File $FILE not found, skipping..."
fi
Comment on lines +34 to +37

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Robust File Existence Check with Opportunity for Enhanced Error Handling

The conditional check using [ -f "$FILE" ] is correctly implemented to determine if the file exists before attempting an upload. The script logs an informative message if the file is not found.

Suggestion: Consider capturing and evaluating the exit code of the aws s3 cp command. This can help in detecting and reporting potential upload failures, ensuring that the CI process fails explicitly if the file upload is critical. For example:

-            aws s3 cp "$FILE" "s3://$BUCKET_NAME/$REMOTE_PATH$FILE_NAME" --acl public-read
+            aws s3 cp "$FILE" "s3://$BUCKET_NAME/$REMOTE_PATH$FILE_NAME" --acl public-read
+            if [ $? -ne 0 ]; then
+              echo "Error: File upload failed."
+              exit 1
+            fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -f "$FILE" ]; then
echo "Uploading $FILE_NAME to S3..."
aws s3 cp "$FILE" "s3://$BUCKET_NAME/$REMOTE_PATH$FILE_NAME" --acl public-read
else
echo "File $FILE not found, skipping..."
fi
if [ -f "$FILE" ]; then
echo "Uploading $FILE_NAME to S3..."
aws s3 cp "$FILE" "s3://$BUCKET_NAME/$REMOTE_PATH$FILE_NAME" --acl public-read
if [ $? -ne 0 ]; then
echo "Error: File upload failed."
exit 1
fi
else
echo "File $FILE not found, skipping..."
fi
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 39-39: no new line character at the end of file

(new-line-at-end-of-file)

10 changes: 10 additions & 0 deletions internal/com.espressif.idf.uploads/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions internal/com.espressif.idf.uploads/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.espressif.idf.uploads</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
Binary file not shown.
1 change: 1 addition & 0 deletions internal/com.espressif.idf.uploads/changes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated on 19th Feb 2025 1:47PM
Binary file not shown.
9 changes: 9 additions & 0 deletions internal/com.espressif.idf.uploads/src/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
*
*/
/**
*
*/
module com.espressif.idf.uploads
{
}