-
Notifications
You must be signed in to change notification settings - Fork 5
142 lines (135 loc) · 4.8 KB
/
example.yaml
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# This workflow contains checks for the examples in the `example` directory
# of the package.
name: Example CI
# Trigger the workflow whenever commits are pushed to the `main` branch or
# development branches with the `-ci` postfix.
# The workflow also runs when it is modified itself or source files outside of
# the `example` directory change because the examples depend on the `toml`
# package. However, source files of the `toml` package for tests can be ignored.
#
# Additionally, the workflow runs once every day at 6am on the `main` branch.
on:
push:
branches:
- "main"
- "*-ci"
paths:
- ".github/workflows/example.yaml"
- "lib/**"
- "tool/*example*.sh"
- "example/**"
- "*.yaml"
schedule:
- cron: "0 6 * * *"
jobs:
# Analyzes the Dart code of the examples (i.e., all `.dart` files in the
# `lib`, `bin` and `test` sub-directories of the example packages in the
# `example` directory) with `dart analyze` or `flutter analyze`.
analyze-examples:
name: Analyze Code of Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.0.0
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1.4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Print Dart SDK Version
run: dart --version
- name: Print Flutter SDK Version
run: flutter --version
- name: Install Dependencies of Examples
run: ./tool/get-example-dependencies.sh
- name: Analyze Code of Examples
run: ./tool/analyze-examples.sh --fatal-infos
# Tests whether all Dart source files of the package i.e., all `.dart` files
# in the `lib`, `bin` and `test` directories) are formatted correctly with
# `dart format`. The `example`s are not analyzed by this job.
format-examples:
name: Check Code Formatting of Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.0.0
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1.4
- name: Print Dart SDK Version
run: dart --version
- name: Install Dependencies of Examples
run: ./tool/get-example-dependencies.sh
- name: Check Code Formatting of Examples
run: "./tool/format-examples.sh --show all
--output none
--set-exit-if-changed"
# Runs the `tool/test.sh` scripts of the `example`s.
test-examples:
name: Test Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.0.0
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1.4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Print Dart SDK Version
run: dart --version
- name: Install Dependencies of Examples
run: ./tool/get-example-dependencies.sh
- name: Run Tests of Examples
run: ./tool/test-examples.sh
# Runs the `tool/test_web.dart` scripts of the `example`s.
test-web-examples:
name: Test Web Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.0.0
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1.4
- name: Print Dart SDK Version
run: dart --version
- name: Add Executables Installed by Pub to PATH
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- name: Install webdev
run: dart pub global activate webdev
- name: Build Web Examples
run: ./tool/build-web-examples.sh
- name: Set DISPLAY Environment Variable.
run: echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Start X Virtual Framebuffer
run: sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
- name: Start WebDriver
run: chromedriver --port=4444 --url-base=/wd/hub &
- name: Wait for WebDriver
run: while ! nc -z localhost 4444; do sleep 0.1; done
- name: Run Tests of Web Examples
run: ./tool/test-web-examples.sh
# Builds the Docker image for the `toml_to_json` example and pushes it to
# DockerHub.
build-and-push-toml-to-json-docker-image:
name: Build and Push `toml_to_json` Docker Image
runs-on: ubuntu-latest
needs:
- analyze-examples
- format-examples
- test-examples
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/toml-to-json:latest
file: example/toml_to_json/Dockerfile