Skip to content

Commit 5eac461

Browse files
authored
修复actions (#1)
* Update go.yml
1 parent 84c39ce commit 5eac461

3 files changed

Lines changed: 152 additions & 20 deletions

File tree

.github/workflows/go.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,31 +119,30 @@ jobs:
119119

120120
- name: Install dependencies
121121
run: |
122-
sudo pip install pytest pytest-asyncio
123-
export PATH="$PATH:~/.local/bin:/opt/hostedtoolcache/Python/3.13.5/x64/bin"
124-
pip install grpcio --force-reinstall
125-
pip install grpcio-tools --force-reinstall
126-
pip install grpclib --force-reinstall
127-
pip install mypy_protobuf --force-reinstall
128-
sudo pip install grpcio --force-reinstall
129-
sudo pip install grpcio-tools --force-reinstall
130-
sudo pip install grpclib --force-reinstall
131-
sudo pip install mypy_protobuf --force-reinstall
122+
/opt/hostedtoolcache/Python/3.13.5/x64/bin/python -m venv venv
123+
source venv/bin/activate
124+
# export PATH="$PATH:~/.local/bin:/opt/hostedtoolcache/Python/3.13.5/x64/bin"
125+
pip install pytest pytest-asyncio --force-reinstall --ignore-installed
126+
pip install grpcio --force-reinstall --ignore-installed
127+
pip install grpcio-tools --force-reinstall --ignore-installed
128+
pip install grpclib --force-reinstall --ignore-installed
129+
pip install mypy_protobuf --force-reinstall --ignore-installed
132130
133-
echo -e '#!/usr/bin/python\nfrom grpclib.plugin.main import main\nimport sys\nsys.exit(main())' > /opt/hostedtoolcache/Python/3.13.5/x64/bin/protoc-gen-grpclib_python
134-
echo -e '#!/usr/bin/python\nfrom mypy_protobuf.main import main\nimport sys\nsys.exit(main())' > /opt/hostedtoolcache/Python/3.13.5/x64/bin/protoc-gen-mypy
135-
chmod +x /opt/hostedtoolcache/Python/3.13.5/x64/bin/protoc-gen-grpclib_python
136-
chmod +x /opt/hostedtoolcache/Python/3.13.5/x64/bin/protoc-gen-mypy
131+
# echo -e '#!/usr/bin/python\nfrom grpclib.plugin.main import main\nimport sys\nsys.exit(main())' > /opt/hostedtoolcache/Python/3.13.5/x64/bin/protoc-gen-grpclib_python
132+
# echo -e '#!/usr/bin/python\nfrom mypy_protobuf.main import main\nimport sys\nsys.exit(main())' > /opt/hostedtoolcache/Python/3.13.5/x64/bin/protoc-gen-mypy
133+
chmod +x venv/bin/protoc-gen-grpclib_python
134+
chmod +x venv/bin/protoc-gen-mypy
137135
138136
- name: Build proto
139137
run: |
140-
export PATH="$PATH:~/.local/bin:/opt/hostedtoolcache/Python/3.13.3/x64/bin"
141-
sudo make debug_proto
138+
source venv/bin/activate
139+
make debug_proto
142140
143141
- name: Run Test
144142
run: |
143+
source venv/bin/activate
145144
cd test
146-
sudo bash ./run.sh
145+
bash ./run.sh
147146
148147
upload-package:
149148
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Release Docker Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-push-image:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Log in to GitHub Container Registry
19+
uses: docker/login-action@v2
20+
with:
21+
registry: ghcr.io
22+
username: ${{ github.actor }}
23+
password: ${{ secrets.PKGTOKEN }}
24+
25+
- name: Set up VERSION environment variable
26+
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
27+
28+
- name: Set up IMAGE_NAME environment variable
29+
run: |
30+
ORG_REPO="${{ github.repository }}"
31+
ORG=$(echo "${ORG_REPO}" | cut -d '/' -f 1 | tr '[:upper:]' '[:lower:]')
32+
REPO=$(echo "${ORG_REPO}" | cut -d '/' -f 2 | tr '[:upper:]' '[:lower:]')
33+
IMAGE_NAME="ghcr.io/${ORG}/${REPO}/${REPO}-app"
34+
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
35+
36+
- name: Pull latest image
37+
run: docker pull ${{ env.IMAGE_NAME }}:latest
38+
39+
- name: Tag image with release version
40+
run: docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
41+
42+
- name: Push image to GitHub Container Registry
43+
run: docker push ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
44+
release:
45+
runs-on: ubuntu-latest
46+
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v4
50+
with:
51+
submodules: true
52+
53+
- name: Set up Go
54+
uses: actions/setup-go@v4
55+
with:
56+
go-version: "1.24.2"
57+
58+
- name: Enable Go Modules and Download Dependencies
59+
run: |
60+
go mod tidy
61+
go mod download
62+
63+
- name: Install protoc
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y protobuf-compiler
67+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
68+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
69+
echo "$GOPATH/bin" >> $GITHUB_PATH
70+
71+
- name: Install Docker
72+
run: |
73+
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
74+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
75+
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
76+
sudo apt-get update
77+
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
78+
79+
- name: Install Docker Compose
80+
run: |
81+
sudo wget "https://github.com/docker/compose/releases/download/v2.33.1/docker-compose-linux-x86_64" -O /usr/bin/docker-compose
82+
sudo chmod +x /usr/bin/docker-compose
83+
84+
- name: Build and Release
85+
run: make release
86+
87+
- name: Upload artifacts 1
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: StealthIMGroupUser
91+
path: ./bin/StealthIMGroupUser
92+
93+
- name: Upload artifacts 2
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: StealthIMGroupUser.exe
97+
path: ./bin/StealthIMGroupUser.exe
98+
99+
- name: Upload artifacts 3
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: StealthIMGroupUser.docker.zst
103+
path: ./bin/StealthIMGroupUser.docker.zst
104+
set-release:
105+
runs-on: ubuntu-latest
106+
needs: release
107+
permissions:
108+
packages: write
109+
contents: write
110+
111+
steps:
112+
- name: Download File Linux
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: StealthIMGroupUser
116+
117+
- name: Download File Windows
118+
uses: actions/download-artifact@v4
119+
with:
120+
name: StealthIMGroupUser.exe
121+
122+
- name: Download File Docker
123+
uses: actions/download-artifact@v4
124+
with:
125+
name: StealthIMGroupUser.docker.zst
126+
127+
- name: Update Release
128+
uses: softprops/action-gh-release@v2
129+
with:
130+
files: |
131+
StealthIMGroupUser
132+
StealthIMGroupUser.exe
133+
StealthIMGroupUser.docker.zst

test/run.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ sleep 3s
122122
echo "Start GroupUser"
123123
cd ${NOWPWD}/test_cache/groupuser && ./StealthIMGroupUser --config=${NOWPWD}/test_cache/groupuser/config.toml > ${NOWPWD}/test_cache/groupuser.log 2>&1 &
124124

125-
sleep 5s
125+
sleep 15s
126126
echo "Start Test"
127127
echo "::group::Test Log"
128128
(pytest test_group_user.py -v; echo "$?">${NOWPWD}/test_cache/.ret) | tee ${NOWPWD}/test_cache/test.log
@@ -142,11 +142,11 @@ echo "::group::Session Log"
142142
cat ${NOWPWD}/test_cache/session.log
143143
echo "::endgroup::"
144144

145-
echo "::group::GroupUser Log"
145+
echo "::group::User Log"
146146
cat ${NOWPWD}/test_cache/user.log
147147
echo "::endgroup::"
148148

149-
echo "::group::User Log"
149+
echo "::group::GroupUser Log"
150150
cat ${NOWPWD}/test_cache/groupuser.log
151151
echo "::endgroup::"
152152

0 commit comments

Comments
 (0)