Skip to content

fix2 #19

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

Merged
merged 19 commits into from
May 13, 2024
Merged

fix2 #19

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
44 changes: 14 additions & 30 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
name: CI
name: ci

on:
pull_request: # Start the job on all PRs
push:
branches:
- master
- main

jobs:
precommit:
Expand All @@ -10,6 +14,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -19,9 +25,6 @@ jobs:
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Set shfmt version environment variable
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV

- name: Cache pip dependencies
uses: actions/cache@v3
with:
Expand All @@ -34,9 +37,8 @@ jobs:
uses: actions/cache@v3
with:
path: /usr/local/bin/shfmt
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
key: ${{ runner.os }}-shfmt-
restore-keys: |
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
${{ runner.os }}-shfmt-

- name: Cache Pre-Commit environments
Expand All @@ -50,21 +52,10 @@ jobs:

- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install

- name: Install shfmt
run: |
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
if [[ ! -f /usr/local/bin/shfmt ]]; then
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
fi
sudo apt-get install shellcheck
rustup component add clippy
echo "uname=$(uname)"
make setuppc
rustup component add rustfmt
rustup component add clippy

- name: Run pre-commits
env:
Expand All @@ -74,14 +65,7 @@ jobs:
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')

git fetch
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)

echo "Default branch is $DEFAULT_BRANCH"
echo "Current SHA is $CUR_SHA"
echo "Default branch = $DEFAULT_BRANCH"
echo "Current SHA = ${{ github. sha }}"

if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
pre-commit run --all
else
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
fi
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"
23 changes: 23 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: integration

on:
pull_request: # Start the job on all PRs
push:
branches:
- master
- main

jobs:
test:
runs-on: ubuntu-latest

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

- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Install dependencies
run: |
sh ./test.sh
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.isort",
"ms-python.black-formatter",
"ms-python.flake8"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"[python]": {
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-python.black-formatter"
},
"flake8.args": ["--config=.ci/flake8.cfg"],
"files.insertFinalNewline": true
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cpa"
version = "0.1.0"
version = "0.1.5"
edition = "2021"

[dependencies]
Expand Down
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@ ifeq ($(shell uname),Darwin)

@echo "Setting up shellcheck (macOS)..."
brew install shellcheck
else ifeq ($(shell uname -s),Linux)
ifeq ($(shell uname -m),x86_64)
@echo "Setting up shfmt for amd64 (Linux)..."
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_amd64"
else ifeq ($(shell uname -m),aarch64)
@echo "Setting up shfmt for arm64 (Linux)..."
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_arm64"
else
@echo "Setting up shfmt (Linux)..."
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_$(shell uname -m)"
@echo "Unsupported architecture $(shell uname -m)! Update this Makefile!"
exit 1
endif
chmod +x shfmt
sudo mv shfmt /usr/local/bin/

sudo mv shfmt /usr/local/bin/shfmt
@echo "Setting up shellcheck (Linux)..."
sudo apt-get install shellcheck || sudo yum install shellcheck || sudo dnf install shellcheck
else
@echo "Unsupported operating system! Update this Makefile or use macOS/Linux."
exit 1
endif

.PHONY: reqtxt
reqtxt:
poetry export -f requirements.txt --output requirements.txt --without-hashes
poetry export -f requirements.txt --output requirements.txt

.PHONY: pcao
pcao:
Expand Down
19 changes: 19 additions & 0 deletions delete_a_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Specific tag to delete
TAG="$1"

# Delete the specific local tag
git tag -d $TAG

# Fetch the current list of tags
git fetch

# Delete the specific remote tag
git push --delete origin $TAG

# Prune local references to remote tags
git fetch --prune --prune-tags

# Delete the specific GitHub release using the GitHub CLI
gh release delete $TAG --yes
File renamed without changes.
43 changes: 12 additions & 31 deletions templates/base/ci.yaml → example/base/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{% raw -%}
name: CI
name: ci

on:
pull_request: # Start the job on all PRs
push:
branches:
- master
- main

jobs:
precommit:
Expand All @@ -11,15 +14,14 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Set shfmt version environment variable
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV

- name: Cache pip dependencies
uses: actions/cache@v3
with:
Expand All @@ -32,9 +34,8 @@ jobs:
uses: actions/cache@v3
with:
path: /usr/local/bin/shfmt
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
key: ${{ runner.os }}-shfmt-
restore-keys: |
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
${{ runner.os }}-shfmt-

- name: Cache Pre-Commit environments
Expand All @@ -48,19 +49,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install

- name: Install shfmt
run: |
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
if [[ ! -f /usr/local/bin/shfmt ]]; then
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
fi
sudo apt-get install shellcheck
make setuppc

- name: Run pre-commits
env:
Expand All @@ -70,15 +59,7 @@ jobs:
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')

git fetch
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)

echo "Default branch is $DEFAULT_BRANCH"
echo "Current SHA is $CUR_SHA"
echo "Default branch = $DEFAULT_BRANCH"
echo "Current SHA = ${{ github. sha }}"

if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
pre-commit run --all
else
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
fi
{%- endraw %}
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"
Loading
Loading