Skip to content

Commit 5d07dc6

Browse files
authored
fix2 (#19)
* clean ci * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean * clean
1 parent 35523cb commit 5d07dc6

26 files changed

+481
-163
lines changed

.github/workflows/ci.yaml

+14-30
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
name: CI
1+
name: ci
22

33
on:
44
pull_request: # Start the job on all PRs
5+
push:
6+
branches:
7+
- master
8+
- main
59

610
jobs:
711
precommit:
@@ -10,6 +14,8 @@ jobs:
1014
steps:
1115
- name: Checkout code
1216
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1319

1420
- name: Set up Python
1521
uses: actions/setup-python@v4
@@ -19,9 +25,6 @@ jobs:
1925
- name: Install Rust Toolchain
2026
uses: dtolnay/rust-toolchain@nightly
2127

22-
- name: Set shfmt version environment variable
23-
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV
24-
2528
- name: Cache pip dependencies
2629
uses: actions/cache@v3
2730
with:
@@ -34,9 +37,8 @@ jobs:
3437
uses: actions/cache@v3
3538
with:
3639
path: /usr/local/bin/shfmt
37-
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
40+
key: ${{ runner.os }}-shfmt-
3841
restore-keys: |
39-
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
4042
${{ runner.os }}-shfmt-
4143
4244
- name: Cache Pre-Commit environments
@@ -50,21 +52,10 @@ jobs:
5052
5153
- name: Install dependencies
5254
run: |
53-
python -m pip install pre-commit
54-
pre-commit install
55-
56-
- name: Install shfmt
57-
run: |
58-
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
59-
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
60-
if [[ ! -f /usr/local/bin/shfmt ]]; then
61-
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
62-
chmod +x shfmt
63-
sudo mv shfmt /usr/local/bin/
64-
fi
65-
sudo apt-get install shellcheck
66-
rustup component add clippy
55+
echo "uname=$(uname)"
56+
make setuppc
6757
rustup component add rustfmt
58+
rustup component add clippy
6859
6960
- name: Run pre-commits
7061
env:
@@ -74,14 +65,7 @@ jobs:
7465
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
7566
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
7667
77-
git fetch
78-
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)
79-
80-
echo "Default branch is $DEFAULT_BRANCH"
81-
echo "Current SHA is $CUR_SHA"
68+
echo "Default branch = $DEFAULT_BRANCH"
69+
echo "Current SHA = ${{ github. sha }}"
8270
83-
if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
84-
pre-commit run --all
85-
else
86-
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
87-
fi
71+
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"

.github/workflows/integration.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: integration
2+
3+
on:
4+
pull_request: # Start the job on all PRs
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Install Rust Toolchain
19+
uses: dtolnay/rust-toolchain@nightly
20+
21+
- name: Install dependencies
22+
run: |
23+
sh ./test.sh

.vscode/extensions.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"ms-python.python",
4+
"ms-python.vscode-pylance",
5+
"ms-python.isort",
6+
"ms-python.black-formatter",
7+
"ms-python.flake8"
8+
]
9+
}

.vscode/settings.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"[python]": {
3+
"editor.formatOnType": true,
4+
"editor.formatOnSave": true,
5+
"editor.defaultFormatter": "ms-python.black-formatter"
6+
},
7+
"flake8.args": ["--config=.ci/flake8.cfg"],
8+
"files.insertFinalNewline": true
9+
}

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cpa"
3-
version = "0.1.0"
3+
version = "0.1.5"
44
edition = "2021"
55

66
[dependencies]

Makefile

+15-5
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,29 @@ ifeq ($(shell uname),Darwin)
1212

1313
@echo "Setting up shellcheck (macOS)..."
1414
brew install shellcheck
15+
else ifeq ($(shell uname -s),Linux)
16+
ifeq ($(shell uname -m),x86_64)
17+
@echo "Setting up shfmt for amd64 (Linux)..."
18+
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64"
19+
else ifeq ($(shell uname -m),aarch64)
20+
@echo "Setting up shfmt for arm64 (Linux)..."
21+
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_arm64"
1522
else
16-
@echo "Setting up shfmt (Linux)..."
17-
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_$(shell uname -m)"
23+
@echo "Unsupported architecture $(shell uname -m)! Update this Makefile!"
24+
exit 1
25+
endif
1826
chmod +x shfmt
19-
sudo mv shfmt /usr/local/bin/
20-
27+
sudo mv shfmt /usr/local/bin/shfmt
2128
@echo "Setting up shellcheck (Linux)..."
2229
sudo apt-get install shellcheck || sudo yum install shellcheck || sudo dnf install shellcheck
30+
else
31+
@echo "Unsupported operating system! Update this Makefile or use macOS/Linux."
32+
exit 1
2333
endif
2434

2535
.PHONY: reqtxt
2636
reqtxt:
27-
poetry export -f requirements.txt --output requirements.txt --without-hashes
37+
poetry export -f requirements.txt --output requirements.txt
2838

2939
.PHONY: pcao
3040
pcao:

delete_a_tag.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Specific tag to delete
4+
TAG="$1"
5+
6+
# Delete the specific local tag
7+
git tag -d $TAG
8+
9+
# Fetch the current list of tags
10+
git fetch
11+
12+
# Delete the specific remote tag
13+
git push --delete origin $TAG
14+
15+
# Prune local references to remote tags
16+
git fetch --prune --prune-tags
17+
18+
# Delete the specific GitHub release using the GitHub CLI
19+
gh release delete $TAG --yes
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
{% raw -%}
2-
name: CI
1+
name: ci
32

43
on:
54
pull_request: # Start the job on all PRs
5+
push:
6+
branches:
7+
- master
8+
- main
69

710
jobs:
811
precommit:
@@ -11,15 +14,14 @@ jobs:
1114
steps:
1215
- name: Checkout code
1316
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1419

1520
- name: Set up Python
1621
uses: actions/setup-python@v4
1722
with:
1823
python-version: "3.10"
1924

20-
- name: Set shfmt version environment variable
21-
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV
22-
2325
- name: Cache pip dependencies
2426
uses: actions/cache@v3
2527
with:
@@ -32,9 +34,8 @@ jobs:
3234
uses: actions/cache@v3
3335
with:
3436
path: /usr/local/bin/shfmt
35-
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
37+
key: ${{ runner.os }}-shfmt-
3638
restore-keys: |
37-
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
3839
${{ runner.os }}-shfmt-
3940
4041
- name: Cache Pre-Commit environments
@@ -48,19 +49,7 @@ jobs:
4849
4950
- name: Install dependencies
5051
run: |
51-
python -m pip install pre-commit
52-
pre-commit install
53-
54-
- name: Install shfmt
55-
run: |
56-
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
57-
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
58-
if [[ ! -f /usr/local/bin/shfmt ]]; then
59-
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
60-
chmod +x shfmt
61-
sudo mv shfmt /usr/local/bin/
62-
fi
63-
sudo apt-get install shellcheck
52+
make setuppc
6453
6554
- name: Run pre-commits
6655
env:
@@ -70,15 +59,7 @@ jobs:
7059
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
7160
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
7261
73-
git fetch
74-
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)
75-
76-
echo "Default branch is $DEFAULT_BRANCH"
77-
echo "Current SHA is $CUR_SHA"
62+
echo "Default branch = $DEFAULT_BRANCH"
63+
echo "Current SHA = ${{ github. sha }}"
7864
79-
if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
80-
pre-commit run --all
81-
else
82-
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
83-
fi
84-
{%- endraw %}
65+
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"

0 commit comments

Comments
 (0)