Skip to content

Commit 185b1fb

Browse files
authored
define GitHub action for CI (#42)
1 parent 850d3fb commit 185b1fb

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
name: Continuous Integration
20+
21+
on:
22+
push:
23+
branches: [ master ]
24+
tags: [ '*' ]
25+
pull_request:
26+
branches: [ master ]
27+
types: [ opened, synchronize, reopened ]
28+
schedule:
29+
- cron: '30 1 * * 1,3,5'
30+
31+
permissions: read-all
32+
33+
jobs:
34+
ci:
35+
runs-on: ubuntu-22.04
36+
env:
37+
PUSH_NIGHTLY: ${{ (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master' }}
38+
PUSH_RELEASE: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
39+
steps:
40+
# Checkout just this repo and run scanCode before we do anything else
41+
- name: Checkout runtime repo
42+
uses: actions/checkout@v3
43+
with:
44+
path: runtime
45+
- name: Scan Code
46+
uses: apache/openwhisk-utilities/scancode@master
47+
48+
# Install core OpenWhisk artifacts needed to build/test anything else
49+
- name: Checkout OpenWhisk core repo
50+
uses: actions/checkout@v3
51+
with:
52+
repository: apache/openwhisk
53+
path: core
54+
- name: Setup Java
55+
uses: actions/setup-java@v3
56+
with:
57+
distribution: 'temurin'
58+
java-version: '11'
59+
- name: Compile and Install Core OpenWhisk
60+
working-directory: core
61+
run: |
62+
./gradlew :tests:compileTestScala
63+
./gradlew install
64+
65+
# Build this repository
66+
- name: Build Runtime
67+
working-directory: runtime
68+
run: |
69+
./gradlew distDocker
70+
71+
# Test this repository
72+
- name: Test Runtime
73+
working-directory: runtime
74+
run: |
75+
./gradlew :tests:checkScalafmtAll
76+
./gradlew :tests:test
77+
78+
# Conditionally publish runtime images to DockerHub
79+
# Important: naming convention for release tags is runtime@version
80+
- name: Docker Login
81+
if: ${{ env.PUSH_NIGHTLY == 'true' || env.PUSH_RELEASE == 'true' }}
82+
uses: docker/login-action@v2
83+
with:
84+
username: ${{ secrets.DOCKERHUB_USER_OPENWHISK }}
85+
password: ${{ secrets.DOCKERHUB_TOKEN_OPENWHISK }}
86+
- name: Push Nightly Images
87+
if: ${{ env.PUSH_NIGHTLY == 'true' }}
88+
working-directory: runtime
89+
run: |
90+
SHORT_COMMIT=$(git rev-parse --short "$GITHUB_SHA")
91+
./gradlew :core:rust1.34:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
92+
./gradlew :core:rust1.34:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
93+
- name: Push Release Images
94+
if: ${{ env.PUSH_RELEASE == 'true' }}
95+
working-directory: runtime
96+
run: |
97+
RUNTIME=${GITHUB_REF_NAME%@*}
98+
IMAGE_TAG=${GITHUB_REF_NAME##*@}
99+
./gradlew :core:$RUNTIME:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$IMAGE_TAG

0 commit comments

Comments
 (0)