Scratch repository for testing automations.
Note in the README that the network is filtered #10
Approved by g1t
4 files+3−600/4 viewed
| 1 | − | # Checks Docker on g1t's hosted runners: a service container reached by | |
| 2 | − | # name, a step run in an image, a build, and a job inside a container. | |
| 3 | − | name: Docker | |
| 4 | − | ||
| 5 | − | on: | |
| 6 | − | workflow_dispatch: | |
| 7 | − | ||
| 8 | − | permissions: | |
| 9 | − | contents: read | |
| 10 | − | ||
| 11 | − | jobs: | |
| 12 | − | services: | |
| 13 | − | name: Services and docker run | |
| 14 | − | runs-on: ubuntu-latest | |
| 15 | − | timeout-minutes: 15 | |
| 16 | − | services: | |
| 17 | − | redis: | |
| 18 | − | image: redis:7-alpine | |
| 19 | − | options: >- | |
| 20 | − | --health-cmd "redis-cli ping" | |
| 21 | − | --health-interval 2s | |
| 22 | − | --health-timeout 2s | |
| 23 | − | --health-retries 15 | |
| 24 | − | ports: | |
| 25 | − | - 6379:6379 | |
| 26 | − | steps: | |
| 27 | − | - uses: actions/checkout@v5 | |
| 28 | − | - name: Docker is there | |
| 29 | − | run: docker version | |
| 30 | − | - name: Reach the service by name | |
| 31 | − | run: docker run --rm redis:7-alpine redis-cli -h redis ping | |
| 32 | − | - name: Build an image | |
| 33 | − | run: | | |
| 34 | − | printf 'FROM alpine:3.20\nRUN echo built > /built\nCMD cat /built\n' > Dockerfile.smoke | |
| 35 | − | docker build -t smoke:latest -f Dockerfile.smoke . | |
| 36 | − | docker run --rm smoke:latest | |
| 37 | − | - name: A step in an image | |
| 38 | − | uses: docker://alpine:3.20 | |
| 39 | − | with: | |
| 40 | − | args: echo hello from a docker step | |
| 41 | − | ||
| 42 | − | container: | |
| 43 | − | name: Job in a container | |
| 44 | − | runs-on: ubuntu-latest | |
| 45 | − | timeout-minutes: 15 | |
| 46 | − | container: | |
| 47 | − | image: node:24-bookworm-slim | |
| 48 | − | steps: | |
| 49 | − | - uses: actions/checkout@v5 | |
| 50 | − | - run: node --version && cat /etc/os-release | head -2 |
| 33 | 33 | ```js | |
| 34 | 34 | standard_deviation([2, 4, 4, 4, 5, 5, 7, 9]); // 2 | |
| 35 | 35 | ``` | |
| 36 | + | ||
| 37 | + | Agent runs here have a filtered network: package registries and g1t only. |
| 9 | 9 | return a * b; | |
| 10 | 10 | } | |
| 11 | 11 | ||
| 12 | − | /** Returns a minus b. */ | |
| 13 | − | function subtract(a, b) { | |
| 14 | − | return a - b; | |
| 15 | − | } | |
| 16 | − | ||
| 17 | 12 | /** Returns base raised to the whole-number exponent; throws a RangeError if exponent is negative. */ | |
| 18 | 13 | function power(base, exponent) { | |
| 19 | 14 | if (exponent < 0) { | |
| ⋯ | |||
| 51 | 46 | return Math.sqrt(variance); | |
| 52 | 47 | } | |
| 53 | 48 | ||
| 54 | − | module.exports = { add, multiply, subtract, power, mean, median, standard_deviation }; | |
| 49 | + | module.exports = { add, multiply, power, mean, median, standard_deviation }; | |
| 1 | 1 | const assert = require("node:assert"); | |
| 2 | 2 | const math = require("./math"); | |
| 3 | − | assert.strictEqual(math.subtract(5, 3), 2); | |
| 4 | 3 | ||
| 5 | 4 | assert.strictEqual(math.add(2, 3), 5); | |
| 6 | 5 | assert.strictEqual(math.multiply(4, 5), 20); | |
| 7 | 6 | assert.strictEqual(math.power(2, 10), 1024); | |
| 8 | 7 | assert.strictEqual(math.power(5, 0), 1); | |
| 9 | 8 | assert.throws(() => math.power(2, -1), RangeError); | |
| 10 | − | assert.strictEqual(math.mean([1, 2, 3]), 2); | |
| 11 | 9 | assert.strictEqual(math.mean([1, 2, 3, 4]), 2.5); | |
| 12 | − | assert.strictEqual(math.median([1, 2, 3]), 2); | |
| 13 | 10 | assert.strictEqual(math.median([3, 1, 2]), 2); | |
| 14 | 11 | assert.strictEqual(math.median([4, 1, 3, 2]), 2.5); | |
| 15 | − | assert.strictEqual(math.standard_deviation([1, 2, 3]), Math.sqrt(2 / 3)); | |
| 16 | 12 | assert.strictEqual(math.standard_deviation([2, 4, 4, 4, 5, 5, 7, 9]), 2); | |
| 17 | 13 | for (const fn of [math.mean, math.median, math.standard_deviation]) { | |
| 18 | 14 | assert.throws(() => fn([]), TypeError); |