forked from victoriadrake/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (67 loc) · 2.36 KB
/
test.yml
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
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
runs-on: ubuntu-latest # Don't care about the runner version but it's required
container:
image: ubuntu:20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# sudo is invoked by the install script.
- name: Install sudo
run: apt-get update && apt-get --assume-yes install sudo
- name: Set up BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.2.1
- name: Check out code
uses: actions/checkout@v2
# https://www.yegor256.com/2014/08/29/docker-non-root.html
- name: Add non-root user
run: |
adduser --disabled-password --gecos '' r
adduser r sudo
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
chown --recursive r:r .
# bats-assert depends on bats-support
# wget ships with desktop Ubuntu
# unzip ships with desktop Ubuntu
- name: Add bats-assert
shell: su r {0}
run: |
sudo apt-get install --assume-yes wget unzip
./add_bats_assertions.sh
- name: Run install script
shell: su r {0}
run: |
cd scripts
sudo -E ./install.sh
# In a real interactive session the PATH is set automatically in the
# expected way by sourcing bashrc. But Github Actions requires this
# syntax, and it takes effect only on subsequent steps.
- name: Set PATH the Github way
shell: su r {0}
run: |
echo "${HOME}/.local/bin" |
sudo tee --append "${GITHUB_PATH}" |
xargs echo Added to path
- name: Test commands
shell: su r {0}
run: |
bats --tap test.bats
- name: Run install script again (test idempotency)
shell: su r {0}
run: |
cd scripts
./install.sh