Skip to content

Commit cabc1b3

Browse files
committed
fix: handle OpenAI API error variants 🐛
- Prevent clippy warnings by denying them - Check for formatting issues with cargo fmt
1 parent 340000c commit cabc1b3

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

.github/workflows/ghcr.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build-and-push-image:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Extract metadata (tags, labels) for Docker
33+
id: meta
34+
uses: docker/metadata-action@v5
35+
with:
36+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
37+
- uses: benjlevesque/[email protected]
38+
id: short-sha
39+
with:
40+
length: 7
41+
- name: Build and push Docker image
42+
id: push
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
push: ${{ github.event_name != 'pull_request' }}
47+
tags: |
48+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
49+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.short-sha.outputs.sha }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
- name: Generate artifact attestation
52+
uses: actions/attest-build-provenance@v2
53+
with:
54+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
55+
subject-digest: ${{ steps.push.outputs.digest }}
56+
push-to-registry: true

.github/workflows/rust.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# File Created: 2025-03-05 11:10:40
1010
#
1111
# Modified By: mingcheng ([email protected])
12-
# Last Modified: 2025-03-17 18:29:18
12+
# Last Modified: 2025-03-18 11:56:05
1313
##
1414

1515
name: Cargo Build & Test

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* File Created: 2025-03-01 17:17:30
1010
*
1111
* Modified By: mingcheng ([email protected])
12-
* Last Modified: 2025-03-17 18:29:42
12+
* Last Modified: 2025-03-18 11:56:08
1313
*/
1414

1515
use aigitcommit::cli::Cli;

src/openai.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* File Created: 2025-03-01 21:55:58
1010
*
1111
* Modified By: mingcheng ([email protected])
12-
* Last Modified: 2025-03-06 17:59:08
12+
* Last Modified: 2025-03-17 22:53:48
1313
*/
1414
use askama::Template;
1515
use async_openai::config::OPENAI_API_BASE;
@@ -66,7 +66,7 @@ impl OpenAI {
6666
});
6767

6868
// Set up proxy if specified
69-
let proxy_addr: String = env::var("OPENAI_APT_PROXY").unwrap_or_else(|_| String::from(""));
69+
let proxy_addr: String = env::var("OPENAI_API_PROXY").unwrap_or_else(|_| String::from(""));
7070
if !proxy_addr.is_empty() {
7171
trace!("Using proxy: {}", proxy_addr);
7272
http_client_builder = http_client_builder.proxy(Proxy::all(proxy_addr).unwrap());

0 commit comments

Comments
 (0)