惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
雷峰网
雷峰网
罗磊的独立博客
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
量子位
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Cisco Talos Blog
Cisco Talos Blog
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
About on SuperTechFans
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Cloudflare Blog
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
Spread Privacy
Spread Privacy
D
DataBreaches.Net
T
The Exploit Database - CXSecurity.com
K
Kaspersky official blog
Cyberwarzone
Cyberwarzone
爱范儿
爱范儿
U
Unit 42
Security Latest
Security Latest
M
MIT News - Artificial intelligence
月光博客
月光博客
Scott Helme
Scott Helme
G
Google Developers Blog
有赞技术团队
有赞技术团队
T
Tor Project blog
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
博客园 - Franky
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
V
V2EX
B
Blog
Apple Machine Learning Research
Apple Machine Learning Research
S
Securelist
博客园 - 三生石上(FineUI控件)
Blog — PlanetScale
Blog — PlanetScale
TaoSecurity Blog
TaoSecurity Blog
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
腾讯CDC
D
Docker
Google Online Security Blog
Google Online Security Blog

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19) 使用 Velero 备份 Kubernetes 集群 Kubernetes Cheat Sheet 开发 Tips(18) 如何构建一个 Java 工程 开发 Tips(17) KubeSpray 安装 Kubernetes 报错 ip in ansible_all_ipv4_addresses 基于 Kubernetes 和 Jenkins 搭建自动化测试系统 在 Kubernetes 上动态创建 Jenkins Slave 使用 Jenkins 进行服务拨测 开发 Tips(16) Kubernetes 签发 Ingress 证书及日常故障运维 Kubernetes 中 Deployment 的基本操作 Kubernetes 中的证书 如何使用 KubeBuilder 开发一个 Operator Kubernetes 1.6.0 安装问题汇总 镜像管理工具 -- Harbor 开发 Tips(15) Docker 如何拉取镜像 开发 Tips(14) 使用 Helm 安装 harbor 开发 Tips(13) 使用 S2I 构建云原生应用 在 Kubernetes 中使用 emptyDir、hostPath、localVolume 开发 Tips(12) 开发 Tips(11) 代码质量分析工具 SonarQube 使用 Kubeadm 安装 Kubernetes 集群 一起来学 Go --(4)常用函数 Kubernetes 中的 Ceph Kubernetes 之 Volumes Kubernetes 之 Labels、Selectors 开发 Tips(10) 开源正在重构商业模式 Kubernetes 之网络 Kubernetes 之 API 使用 Helm 和 Operator 快速部署 Prometheus Kubernetes 复杂有状态应用管理框架 -- Operator Kubernetes 的包管理器 -- Helm 一起来学 Go --(3)Go Modules 如何一步一步地优化博客方案 kubectl 实用指南 Kubernetes 中的基本概念 搭建远程 Kubernetes 开发环境 大公司和小公司的 ToB 思路 开发 Tips(9) Go 入门指南 一起来学 Go --(2)数据与逻辑结构 如何预防 Web 富文本中的 XSS 攻击 django-xss-cleaner 云工作时代 一起来学 Go --(1)背景与特点 SaaS 开发团队的不同阶段 你不知道的 Git 使用技巧 输出既服务 微服务设计 继续奔跑 开发 Tips(8) 从账户安全到二次验证 Django 性能之数据库查询优化 Django 性能之分库分表 敏捷开发之研发流程 打造一致性的团队 开发 Tips(7) Pytest 进阶学习之 Mock PaaS 部署之 buildpack Go 开发配置 领域输出才是 PaaS 的核心竞争力 Pytest 入门学习 开发 Tips(6) 如何使用 Jenkins、Docker、GitLab 搭建 Django 自动化部署流程
GitHub Actions 在线调试工具:debugger-action
微信公众号 · 2021-01-18 · via 陈少文的网站

1. Debug 到想跑路

GitHub Actions 是 GitHub 在 2018 年 10 月推出的持续集成服务。对于开源项目,免费提供无限时长的构建时间,同时支持 Linux、MacOs、Windows 系统,非常招人喜爱。

但是,最近的一次经历改变了我的看法。我给同事的仓库,提交了一个 improvement: build and ci 的 commit ,用于完善持续构建的功能。如下图:

这只是 Debug 过程中的几条记录。在本地测试通过,但是添加到 workflows 就报错。花了一天多时间,提交了不下几十次用于测试。这是一个私有的仓库,只能遵循 Merge Requests 的研发流程。这倒不要紧,关键是老板 watch 了这个仓库。每次构建失败,都会收到一条通知邮件,还赶上年终,泪奔 ~~~

2. debugger-action 诞生记

周末正好看到 PingCap 有个 Hackathon 的活动,用较短的时间集中完成一个功能。灵感一闪,我周末就用 GitHub Actions 来解决一下 Debug 到想跑路的问题。

看了下 TypeScript 的语法,凭借之前 SaaS 全栈开发的一点底子,还有强大的 Google 搜索引擎,就把事情给办了。

一起来看看怎么调试 GitHub Actions 吧。下面是一个 Go 的 workflows 环境:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
name: Build

on:
  push:
    branches: [master]

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go 1.14
        uses: actions/setup-go@v1
        with:
          go-version: 1.14

      - name: Check out code into the Go module directory
        uses: actions/checkout@v2

      - uses: shaowenchen/debugger-action@v1
        name: debugger
        timeout-minutes: 30
        continue-on-error: true
        with:
          frp_server_addr: ${{ secrets.FRP_SERVER_ADDR }}
          frp_server_port: ${{ secrets.FRP_SERVER_PORT }}
          frp_token: ${{ secrets.FRP_TOKEN }}
          ssh_port: ${{ secrets.SSH_PORT }}

运行起来之后,Runner 会 hold 30 分钟,开发者可以通过 ssh 远程登陆到 Runner 上执行命令,进行调试。

1
ssh root@frp_server_addr -p ssh_port

输入 root 密码: root

这样就进入了 Runner 的执行环境,debugger-actions 目前支持 Linux 和 MacOS 的构建环境。

3. 配置和使用 debugger-action

3.1 搭建 Frp Server

参考之前写过的一篇文档 《使用 frp 将本地服务发布到公网》 ,其中有一键安装的脚本。

安装成功会得到一个配置:

==============================================
You Server IP      : x.x.x.x
Bind port          : 5443
KCP support        : true
vhost http port    : 80
vhost https port   : 443
Dashboard port     : 6443
token              : x
tcp_mux            : true
Max Pool count     : 200
Log level          : info
Log max days       : 30
Log file           : enable
==============================================

如果没有服务器的同学,也可以使用我在项目 issues 中提供的测试 Frp Server ,https://github.com/shaowenchen/debugger-action/issues/3 。

3.2 配置秘钥

在 Settings 页面的 Secrets 中,添加三个秘钥,FRP_SERVER_ADDR, FRP_SERVER_PORT, FRP_TOKEN ,秘钥值来自上一步。如下图:

SecretsFrp 对应值
FRP_SERVER_ADDRYou Server IP
FRP_SERVER_PORTBind port
FRP_TOKENtoken

SSH_PORT 可以任意指定,但不同 Workflows 中不能相同。SSH_PORT 相同,会导致 Frp Client 起不来。当然,也可以填写一个固定值,只是不那么安全。

3.3 添加 debugger-action

在 Workflows 中需要 Debug 的地方,添加下面的 yaml 片段。

1
2
3
4
5
6
7
8
9
- uses: shaowenchen/debugger-action@v1
  name: debugger
  timeout-minutes: 30
  continue-on-error: true
  with:
    frp_server_addr: ${{ secrets.FRP_SERVER_ADDR }}
    frp_server_port: ${{ secrets.FRP_SERVER_PORT }}
    frp_token: ${{ secrets.FRP_TOKEN }}
    ssh_port: ${{ secrets.SSH_PORT }}

其中 timeout-minutes 用于设置需要 Debug 的时长。GitHub Actions 中,每个 Job 允许执行的最大时长为 6 个小时。

4. 使用测试

使用 ssh 命令,root/root(账户/密码),登陆到 Runner。

1
ssh root@frp_server_addr -p ssh_port

在 Frp Dashboard 中,也可以看到相关连接。

5. 一些测试用例

5.1 buildx 构建环境

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
name: buildx
on:
  push:
    branches: [master]

jobs:
  hello:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - uses: shaowenchen/debugger-action@v1
        name: debugger
        timeout-minutes: 30
        continue-on-error: true
        with:
          frp_server_addr: ${{ secrets.FRP_SERVER_ADDR }}
          frp_server_port: ${{ secrets.FRP_SERVER_PORT }}
          frp_token: ${{ secrets.FRP_TOKEN }}
          ssh_port: 29001

命令行测试:

1
2
3
4
docker ps

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS               NAMES
94e481a9d5a5        moby/buildkit:buildx-stable-1   "buildkitd --allow-i…"   23 minutes ago      Up 23 minutes                           buildx_buildkit_builder-1cfe11cc-90d5-4518-9d89-a05765ac30620

5.2 一个 Kind 集群

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
name: kind
on:
  push:
    branches: [master]

jobs:
  hello:
    runs-on: ubuntu-latest
    steps:
      - name: Creating kind cluster
        uses: helm/kind-action@v1.0.0-rc.1
      - uses: shaowenchen/debugger-action@v1
        name: debugger
        timeout-minutes: 30
        continue-on-error: true
        with:
          frp_server_addr: ${{ secrets.FRP_SERVER_ADDR }}
          frp_server_port: ${{ secrets.FRP_SERVER_PORT }}
          frp_token: ${{ secrets.FRP_TOKEN }}
          ssh_port: 29002

命令行测试:

1
2
3
4
kubectl get node

NAME                          STATUS   ROLES    AGE   VERSION
chart-testing-control-plane   Ready    master   24m   v1.17.0

5.3 一个 MacOS 环境

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
name: macos-shell
on:
  push:
    branches: [master]

jobs:
  hello:
    runs-on: macos-latest
    steps:
      - uses: shaowenchen/debugger-action@v1
        name: debugger
        timeout-minutes: 30
        continue-on-error: true
        with:
          frp_server_addr: ${{ secrets.FRP_SERVER_ADDR }}
          frp_server_port: ${{ secrets.FRP_SERVER_PORT }}
          frp_token: ${{ secrets.FRP_TOKEN }}
          ssh_port: 29003

命令行测试:

1
2
3
Mac-1610933038460:~ runner$ uname -a

Darwin Mac-1610933038460.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64

6. 参考