Skip to content

Commit

Permalink
MacOS sudo free
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed Feb 4, 2025
1 parent b672ac8 commit 06a054d
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 113 deletions.
19 changes: 19 additions & 0 deletions '
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MacOS sudo free

Signed-off-by: Joel Winarske <[email protected]>

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Tue Feb 4 09:26:57 2025 -0800
#
# On branch jw/macos
# Your branch is up to date with 'origin/jw/macos'.
#
# Changes to be committed:
# new file: .github/workflows/macos.yaml
# renamed: .github/workflows/workspace-automation.yml -> .github/workflows/ubuntu.yml
# modified: common.py
# modified: configs/toolchain-llvm-18.json
# modified: flutter_workspace.py
#
57 changes: 57 additions & 0 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: macos-workspace-automation

on:
pull_request:
types: [ opened, synchronize, reopened, closed ]
release:
types: [ published, created, edited ]
workflow_dispatch:
schedule:
# daily
- cron: '0 0 * * *'

jobs:

workspace-automation:

env:
NONINTERACTIVE: 1
HOMEBREW_NO_AUTO_UPDATE: 1

strategy:
matrix:
os: [ macos-14, macos-15 ]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Brew fixup
run: |
brew uninstall [email protected] | true
brew unlink [email protected] | true
brew uninstall [email protected] | true
brew link --overwrite openssl@3
brew untap homebrew/cask | true
brew untap homebrew/core | true
brew install ruby | true
brew update
brew upgrade
brew cleanup |true
brew doctor |true
ruby -v
- name: Create workspace
run: |
./flutter_workspace.py
- name: Test workspace
run: |
source ./setup_env.sh
flutter doctor -v
dart --version
File renamed without changes.
45 changes: 45 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import errno
import os
import sys
import subprocess

from platform import system
from sys import stderr as stream

# use kiB's
Expand Down Expand Up @@ -261,6 +263,49 @@ def fetch_https_binary_file(url, filename, redirect, headers, cookie_file, netrc
return success


def get_ws_folder():
if "FLUTTER_WORKSPACE" in os.environ:
workspace = os.environ.get('FLUTTER_WORKSPACE')
else:
workspace = os.getcwd()
return workspace


def get_host_type() -> str:
"""returns host type in lower case"""
return system().lower().rstrip()


def reset_sudo_timestamp():
"""invalidate sudo timestamp file"""
if get_host_type() == "linux":
subprocess.check_call(['sudo', '-k'], stdout=subprocess.DEVNULL)


def validate_sudo_user_timestamp(args):
"""read password from standard input if available"""
if os.path.exists(args.stdin_file):
stdin_file = open(args.stdin_file)
if get_host_type() == "linux":
subprocess.check_call(['sudo', '-S', '-v'], stdout=subprocess.DEVNULL, stdin=stdin_file)
else:
if get_host_type() == "linux":
subprocess.check_call(['sudo', '-v'], stdout=subprocess.DEVNULL)


def validate_sudo_user():
"""update user's sudo timestamp without running a command"""
if get_host_type() == "linux":
subprocess.check_call(['sudo', '-v'], stdout=subprocess.DEVNULL)


def chown_workspace(username, workspace):
"""chown workspace if linux"""
if get_host_type() == "linux":
cmd = ['sudo', 'chown', '-R', username, workspace]
subprocess.check_call(cmd, cwd=workspace, stdout=subprocess.DEVNULL)


def test_internet_connection() -> bool:
"""Test internet by connecting to nameserver"""
import pycurl
Expand Down
16 changes: 13 additions & 3 deletions configs/toolchain-llvm-18.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
"load": true,
"supported_archs": [
"aarch64",
"arm64",
"x86_64"
],
"supported_host_types": [
"ubuntu",
"fedora"
"darwin",
"fedora",
"ubuntu"
],
"type": "toolchain",
"toolchain": "llvm",
"prefer_llvm": "18",
"env": {
"VERSION": "18"
"VERSION": "18",
"NONINTERACTIVE": "1"
},
"runtime": {
"pre-requisites": {
Expand All @@ -34,6 +37,13 @@
]
}
},
"arm64": {
"darwin": {
"cmds": [
"brew install llvm"
]
}
},
"x86_64": {
"ubuntu": {
"cmds": [
Expand Down
Loading

0 comments on commit 06a054d

Please sign in to comment.