Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 04f8e83

Browse files
authoredMar 14, 2022
Replace Travis CI with Github Actions (p4lang#378)
1 parent bd889ab commit 04f8e83

9 files changed

+194
-125
lines changed
 
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Any branch uploads
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
any-branch-uploads:
10+
if: ${{ github.repository == 'p4lang/p4runtime' }}
11+
runs-on: [ubuntu-latest]
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Build spec
15+
run: |
16+
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
17+
ls docs/v1/build
18+
- name: Upload spec to S3 if needed
19+
uses: jakejarvis/s3-sync-action@v0.5.1
20+
with:
21+
args: --acl public-read --follow-symlinks --delete
22+
env:
23+
AWS_S3_BUCKET: 'p4runtime'
24+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
25+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26+
AWS_REGION: 'us-west-2'
27+
SOURCE_DIR: 'docs/v1/build'
28+
DEST_DIR: ci/${{ github.ref_name }} # only runs for push events

‎.github/workflows/codegen.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Check generated code
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
check-codegen:
13+
runs-on: [ubuntu-latest]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Compile protobufs
17+
run: |
18+
docker build -t p4runtime-ci -f codegen/Dockerfile .
19+
docker run -t p4runtime-ci /p4runtime/codegen/compile_protos.sh /tmp
20+
- name: Check codegen
21+
run: |
22+
./CI/check_codegen.sh
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Main branch uploads
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
main-branch-uploads:
10+
if: ${{ github.repository == 'p4lang/p4runtime' }}
11+
runs-on: [ubuntu-latest]
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
# fetch all history for all branches and tags
16+
fetch-depth: 0
17+
- name: Build spec
18+
run: |
19+
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
20+
ls docs/v1/build
21+
- name: Upload spec to S3
22+
uses: jakejarvis/s3-sync-action@v0.5.1
23+
with:
24+
args: --acl public-read --follow-symlinks --delete
25+
env:
26+
AWS_S3_BUCKET: 'p4runtime'
27+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
28+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
29+
AWS_REGION: 'us-west-2'
30+
SOURCE_DIR: 'docs/v1/build'
31+
DEST_DIR: docs/main
32+
- name: Prepare spec for upload to gh-pages
33+
run: |
34+
git checkout gh-pages
35+
mkdir -p spec
36+
rm -rf spec/main
37+
cp -r docs/v1/build spec/main
38+
- name: Upload spec to gh-pages
39+
uses: EndBug/add-and-commit@v9
40+
with:
41+
add: 'spec'
42+
author_name: 'P4Runtime CI'
43+
author_email: 'p4-api@lists.p4.org'
44+
default_author: github_actions
45+
message: 'Publish spec from Github Actions'
46+
commit: '--amend'
47+
push: 'origin gh-pages --force'

‎.github/workflows/spec.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build spec
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
madoko-lint:
13+
runs-on: [ubuntu-latest]
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Run linter
17+
run: |
18+
./tools/madokolint.py docs/v1/P4Runtime-Spec.mdk
19+
20+
build-spec:
21+
runs-on: [ubuntu-latest]
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Build spec
25+
run: |
26+
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
27+
ls docs/v1/build

‎.github/workflows/tag-uploads.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Tag uploads
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
tag-uploads:
10+
if: ${{ github.repository == 'p4lang/p4runtime' }}
11+
runs-on: [ubuntu-latest]
12+
env:
13+
TAG: ${{ github.ref }}
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
# fetch all history for all branches and tags
18+
fetch-depth: 0
19+
- name: Build spec
20+
run: |
21+
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
22+
ls docs/v1/build
23+
- name: Upload spec to S3
24+
uses: jakejarvis/s3-sync-action@v0.5.1
25+
with:
26+
args: --acl public-read --follow-symlinks --delete
27+
env:
28+
AWS_S3_BUCKET: 'p4runtime'
29+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
30+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
31+
AWS_REGION: 'us-west-2'
32+
SOURCE_DIR: 'docs/v1/build'
33+
DEST_DIR: docs/${{ github.ref }}
34+
- name: Prepare spec for upload to gh-pages
35+
run: |
36+
git checkout gh-pages
37+
mkdir -p spec
38+
rm -rf spec/$TAG
39+
cp -r docs/v1/build spec/$TAG
40+
- name: Upload spec to gh-pages
41+
uses: EndBug/add-and-commit@v9
42+
with:
43+
add: 'spec'
44+
author_name: 'P4Runtime CI'
45+
author_email: 'p4-api@lists.p4.org'
46+
default_author: github_actions
47+
message: 'Publish spec from Github Actions'
48+
commit: '--amend'
49+
push: 'origin gh-pages --force'
50+
51+
publish-to-pypi:
52+
name: Publish a Python distribution to PyPI
53+
if: ${{ github.repository == 'p4lang/p4runtime' }}
54+
runs-on: [ubuntu-latest]
55+
steps:
56+
- uses: actions/checkout@v3
57+
- uses: pypa/gh-action-pypi-publish@release/v1
58+
with:
59+
user: __token__
60+
password: ${{ secrets.PYPI_API_TOKEN }}
61+
packages_dir: py/
62+
skip_existing: true

‎.travis.yml

-83
This file was deleted.

‎CI/deploy.sh

-33
This file was deleted.

‎docs/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,16 @@ change the object's aspect ratio.)
183183

184184
## CI upload of built documents
185185

186-
Travis takes care of uploading the built HTML version of the spec to Github. The
187-
latest working draft (main branch) can be found
186+
Github Actions take care of uploading the built HTML version of the spec to
187+
Github. The latest working draft (main branch) can be found
188188
[here](https://p4.org/p4runtime/spec/main/P4Runtime-Spec.html).
189189

190190
Additionally, you can access the HTML & PDF versions of the spec for any given
191191
branch of this repository by using the following URLs:
192-
* `https://s3-us-west-2.amazonaws.com/p4runtime/travis/<your_branch_name>/P4Runtime-Spec.html`
192+
* `https://s3-us-west-2.amazonaws.com/p4runtime/ci/<your_branch_name>/P4Runtime-Spec.html`
193193
for the **HTML** version
194-
* `https://s3-us-west-2.amazonaws.com/p4runtime/travis/<your_branch_name>/P4Runtime-Spec.pdf`
194+
* `https://s3-us-west-2.amazonaws.com/p4runtime/ci/<your_branch_name>/P4Runtime-Spec.pdf`
195195
for the **PDF** version
196196

197-
Unfortunately, because of how Travis encrypts environment variables (which are
198-
required to upload documents to S3), this does not work for branches in forked
197+
Unfortunately, for security reasons, this does not work for branches in forked
199198
repositories, even for opened pull requests.

‎docs/tools/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Dockerfile.madoko is used to build a Docker image which we use to render the
2-
P4Runtime specification (HTML & PDF) in Travis CI. The image can also be used
3-
locally to build the specification without having to worry about installing all
4-
the dependencies yourself.
2+
P4Runtime specification (HTML & PDF) in CI. The image can also be used locally
3+
to build the specification without having to worry about installing all the
4+
dependencies yourself.
55

66
Only maintainers of this repository need to build the Docker image when a new
77
image needs to be pushed to dockerhub. Contributors to the specification can

0 commit comments

Comments
 (0)
Please sign in to comment.