Skip to content

Commit 6ed3486

Browse files
authored
build: add github action workflow to run random examples every 24h
PR-URL: stdlib-js#1005 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent 0b1ec25 commit 6ed3486

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2023 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Workflow name:
20+
name: random_examples
21+
22+
# Workflow triggers:
23+
on:
24+
# Trigger the workflow every 24 hours:
25+
schedule:
26+
- cron: '0 0 * * *'
27+
28+
# Allow the workflow to be manually run:
29+
workflow_dispatch:
30+
31+
# Workflow jobs:
32+
jobs:
33+
34+
# Define a job for running random examples...
35+
process:
36+
37+
# Define a display name:
38+
name: 'Run random examples'
39+
40+
# Define the type of virtual host machine:
41+
runs-on: ubuntu-latest
42+
43+
# Define the sequence of job steps...
44+
steps:
45+
# Checkout the repository:
46+
- name: 'Checkout repository'
47+
uses: actions/checkout@v3
48+
with:
49+
# Specify whether to remove untracked files before checking out the repository:
50+
clean: true
51+
52+
# Limit clone depth to the last 1000 commits:
53+
fetch-depth: 1000
54+
55+
# Specify whether to download Git-LFS files:
56+
lfs: false
57+
timeout-minutes: 10
58+
59+
# Install Node.js:
60+
- name: 'Install Node.js'
61+
uses: actions/setup-node@v3
62+
with:
63+
node-version: '18' # 'lts/*'
64+
timeout-minutes: 5
65+
66+
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
67+
- name: 'Install dependencies'
68+
run: |
69+
make install-node-modules || make install-node-modules || make install-node-modules
70+
timeout-minutes: 15
71+
72+
# Run JavaScript examples:
73+
- name: 'Run JavaScript examples'
74+
run: |
75+
make examples-random-javascript RANDOM_SELECTION_SIZE=50
76+
timeout-minutes: 60

tools/make/lib/examples/javascript.mk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,27 @@ examples-javascript-files: $(NODE_MODULES)
7070
done
7171

7272
.PHONY: examples-javascript-files
73+
74+
#/
75+
# Runs random JavaScript examples consecutively.
76+
#
77+
# @param {string} [PACKAGES_PATTERN='package.json'] - filename pattern for identifying packages
78+
# @param {string} [PACKAGES_FILTER='.*/.*'] - filepath pattern for finding packages
79+
# @param {string} [RANDOM_SELECTION_SIZE=100] - number of packages
80+
#
81+
# @example
82+
# make examples-random-javascript
83+
#
84+
# @example
85+
# make examples-random-javascript RANDOM_SELECTION_SIZE=10
86+
#/
87+
examples-random-javascript: $(NODE_MODULES)
88+
$(QUIET) make list-random-lib-pkgs | while read -r pkg; do \
89+
echo ""; \
90+
echo "Running example: $$pkg"; \
91+
NODE_ENV="$(NODE_ENV_EXAMPLES)" \
92+
NODE_PATH="$(NODE_PATH_EXAMPLES)" \
93+
make examples-javascript EXAMPLES_FILTER="$$pkg/.*" || exit 1; \
94+
done
95+
96+
.PHONY: examples-random-javascript

tools/make/lib/ls/pkgs/lib.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ FIND_LIB_PACKAGES_CMD ?= find $(find_kernel_prefix) $(SRC_DIR) $(FIND_LIB_PACKAG
3636
# Define the list of packages:
3737
LIB_PACKAGES ?= $(shell $(FIND_LIB_PACKAGES_CMD))
3838

39+
# Define the default number of random packages
40+
RANDOM_SELECTION_SIZE ?= 100
41+
3942

4043
# RULES #
4144

@@ -55,3 +58,21 @@ list-lib-pkgs:
5558
$(QUIET) find $(find_kernel_prefix) "$(SRC_DIR)" $(FIND_LIB_PACKAGES_FLAGS) | xargs printf '%s\n'
5659

5760
.PHONY: list-lib-pkgs
61+
62+
#/
63+
# Prints a random list of packages.
64+
#
65+
# @param {string} [PACKAGES_PATTERN='package.json'] - filename pattern for identifying packages
66+
# @param {string} [PACKAGES_FILTER='.*/.*'] - filepath pattern for finding packages
67+
# @param {string} [RANDOM_SELECTION_SIZE=100] - number of packages
68+
#
69+
# @example
70+
# make list-random-lib-pkgs
71+
#
72+
# @example
73+
# make list-random-lib-pkgs RANDOM_SELECTION_SIZE=10
74+
#/
75+
list-random-lib-pkgs:
76+
$(QUIET) make list-lib-pkgs | sort -R | head -n $(RANDOM_SELECTION_SIZE)
77+
78+
.PHONY: list-random-lib-pkgs

0 commit comments

Comments
 (0)