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

ci(workflows) add GitHub Actions workflow for preview builds #2446

Merged
merged 32 commits into from
Sep 20, 2024
Merged
Changes from 13 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
100 changes: 100 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: preview

on:
workflow_dispatch:
push:
branches:
- ci-preview
glihm marked this conversation as resolved.
Show resolved Hide resolved

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.80.0
steebchen marked this conversation as resolved.
Show resolved Hide resolved
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}

jobs:
build:
name: Build
runs-on: ubuntu-latest-4-cores

steps:
- uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v1
Copy link

Choose a reason for hiding this comment

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

Update Swatinem/rust-cache action to a newer version

Ohayo, sensei! The Swatinem/rust-cache@v1 action is outdated. Updating to the latest version will ensure better compatibility and performance.

Apply this diff to update the action version:

-          - uses: Swatinem/rust-cache@v1
+          - uses: Swatinem/rust-cache@v2
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
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
Tools
actionlint

22-22: the runner of "Swatinem/rust-cache@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: "25.x"

Copy link

Choose a reason for hiding this comment

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

Remove unnecessary 'repo-token' input from 'arduino/setup-protoc@v2'

Ohayo, sensei! The repo-token input is not required for the arduino/setup-protoc@v2 action. Removing it can prevent potential misconfigurations.

Apply this diff to remove the unnecessary input:

       - uses: arduino/setup-protoc@v2
         with:
-          repo-token: ${{ secrets.GITHUB_TOKEN }}
           version: "25.x"
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
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: "25.x"
- uses: arduino/setup-protoc@v2
with:
version: "25.x"

- name: Build binaries
run: |
cargo build -r --bin katana
cargo build -r --bin torii
cargo build -r --bin sozo

- name: Archive binaries
id: artifacts
env:
VERSION_NAME: v${{ needs.prepare.outputs.tag_name }}
Copy link

Choose a reason for hiding this comment

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

Undefined 'prepare' in 'needs.prepare.outputs.tag_name'

Ohayo, sensei! The variable needs.prepare.outputs.tag_name refers to a job named prepare, which isn't defined in the workflow. This will cause the workflow to fail due to an undefined reference.

To fix this, either define a prepare job that outputs tag_name, or modify the variable to correctly reference an existing job's output. If tag_name is not needed, you can set a default value.

For example, set VERSION_NAME to a default value:

-              VERSION_NAME: v${{ needs.prepare.outputs.tag_name }}
+              VERSION_NAME: "v1.0.0"  # Replace with the appropriate version
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
VERSION_NAME: v${{ needs.prepare.outputs.tag_name }}
VERSION_NAME: "v1.0.0" # Replace with the appropriate version
Tools
actionlint

38-38: property "prepare" is not defined in object type {}

(expression)

run: |
tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo
echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

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

ShellCheck SC2086: Quote variables to prevent globbing and word splitting

Ohayo, sensei! In your shell script, the variable $GITHUB_OUTPUT should be wrapped in double quotes to prevent word splitting and globbing issues.

Apply this diff to fix the issue:

-              echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT
+              echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> "$GITHUB_OUTPUT"
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
echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT
echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> "$GITHUB_OUTPUT"

shell: bash

- name: Move Binaries
run: |
mkdir -p artifacts/linux/amd64/
mv target/release/katana artifacts/linux/amd64/
mv target/release/torii artifacts/linux/amd64/
mv target/release/sozo artifacts/linux/amd64/
shell: bash
steebchen marked this conversation as resolved.
Show resolved Hide resolved

# Upload these for use with the Docker build later
- name: Upload docker binaries
uses: actions/upload-artifact@v3
with:
name: binaries
path: artifacts
retention-days: 1

docker-build-and-push:
runs-on: ubuntu-latest
needs: [build]

steps:
- name: Checkout repository
uses: actions/checkout@v2
Copy link

Choose a reason for hiding this comment

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

Update actions/checkout action to the latest version

Ohayo, sensei! The actions/checkout@v2 action is outdated. Updating to the latest version will provide consistency and utilize the latest features.

Apply this diff to update the action version:

-          uses: actions/checkout@v2
+          uses: actions/checkout@v4
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
uses: actions/checkout@v2
uses: actions/checkout@v4
Tools
actionlint

66-66: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts

- name: TEMP LS
run: ls -R artifacts

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Copy link

Choose a reason for hiding this comment

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

Update docker/setup-buildx-action to the latest version

Ohayo, sensei! The docker/setup-buildx-action@v1 action is outdated. Updating to the latest version ensures improved functionality and support.

Apply this diff to update the action version:

-          - name: Set up Docker Buildx
-            uses: docker/setup-buildx-action@v1
+          - name: Set up Docker Buildx
+            uses: docker/setup-buildx-action@v2
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
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
Tools
actionlint

78-78: the runner of "docker/setup-buildx-action@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


- name: Login to GitHub Container Registry
uses: docker/login-action@v1
Copy link

Choose a reason for hiding this comment

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

Update docker/login-action to the latest version

Ohayo, sensei! The docker/login-action@v1 action is outdated. Updating to the latest version will enhance security and compatibility.

Apply this diff to update the action version:

-          - name: Login to GitHub Container Registry
-            uses: docker/login-action@v1
+          - name: Login to GitHub Container Registry
+            uses: docker/login-action@v2
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
uses: docker/login-action@v1
uses: docker/login-action@v2
Tools
actionlint

81-81: the runner of "docker/login-action@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set outputs
id: vars
run: |
git config --global --add safe.directory '*'
glihm marked this conversation as resolved.
Show resolved Hide resolved
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
Copy link

Choose a reason for hiding this comment

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

ShellCheck SC2086: Quote variables to prevent globbing and word splitting

Ohayo, sensei! In your shell script, the variable $GITHUB_OUTPUT should be wrapped in double quotes to prevent word splitting and globbing issues.

Apply this diff to fix the issue:

-              echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
+              echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
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
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"


- name: Build and push docker image
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }}
platforms: linux/amd64
build-contexts: |
artifacts=artifacts
Loading