-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpushToGitHub.pl
121 lines (97 loc) · 4.42 KB
/
pushToGitHub.pl
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
#!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/
#-------------------------------------------------------------------------------
# Push Btree block code to GitHub
# Philip R Brenan at gmail dot com, Appa Apps Ltd Inc., 2024
#-------------------------------------------------------------------------------
use warnings FATAL => qw(all);
use strict;
use Carp;
use Data::Dump qw(dump);
use Data::Table::Text qw(:all);
use GitHub::Crud qw(:all);
use feature qw(say current_sub);
my $home = q(/home/phil/btreeBlock/); # Home folder
my $user = q(philiprbrenan); # User
my $repo = q(btreeBlock); # Repo
my $wf = q(.github/workflows/main.yml); # Work flow on Ubuntu
my @ext = qw(.java .md .pl .txt .png .py .sv .tb .v); # All files to upload to github
# @ext = qw(.java .md .pl .txt); # Reduced set of files to upload to github
push my @files, searchDirectoryTreesForMatchingFiles($home, @ext); # Files to upload
@files = grep {!m(z/|machine|perl|vivado/)} @files; # Remove files that do not need to be saved
@files = grep {!m(verilog/|git/objects/)} @files; # Remove files that do not need to be saved
my @java = map {fn $_} grep {fe($_) eq q(java) && fn($_) !~ m(Able\Z)} @files; # Java files to test do not include interfaces
if (0) # Upload via github crud
{for my $s(@files) # Upload each selected file
{my $c = readBinaryFile $s; # Load file
$c = expandWellKnownWordsAsUrlsInMdFormat $c if $s =~ m(README); # Expand README
my $t = swapFilePrefix $s, $home; # File on github
my $w = writeFileUsingSavedToken($user, $repo, $t, $c); # Write file into github
lll "$w $t";
}
}
else # Upload files via git
{qx(git add *; git commit -m aaa; git push --force); # Force used to overcome changes to workflow file which is used as a surrogate for any change
}
writeFileUsingSavedToken($user, $repo, q(.config/geany/snippets.conf), # Save the snippets file as this was the thing I missed most after a rebuild
readFile(q(/home/phil/.config/geany/snippets.conf)));
writeFileUsingSavedToken($user, $repo, q(.config/geany/keybindings.conf), # Save the keybindings file for the same reason
readFile(q(//home/phil/.config/geany/keybindings.conf)));
if (1) # Write workflow
{my $d = dateTimeStamp;
my $c = q(com/AppaApps/Silicon); # Package to classes folder
my $j = join ', ', @java; # Java files
my $y = <<"END";
# Test $d
name: Test
run-name: $repo
on:
push:
paths:
- '**/main.yml'
concurrency:
group: \${{ github.workflow }}-\${{ github.ref }}
cancel-in-progress: true
jobs:
test:
permissions: write-all
runs-on: ubuntu-latest
strategy:
matrix:
task: [$j]
steps:
- uses: actions/checkout\@v4
with:
ref: 'main'
- name: 'JDK 22'
uses: oracle-actions/setup-java\@v1
with:
website: jdk.java.net
- name: Verilog install
if: matrix.task == 'BtreePA'
run: |
sudo apt install iverilog
- name: Install Tree
run:
sudo apt install tree
- name: Position files in package
run: |
mkdir -p $c
cp `find . -name "*.java"` $c
- name: Files
run:
tree
- name: Compile
run: |
javac -g -d Classes -cp Classes `find $c -name "*.java"`
END
for my $j(@java) # Java files
{$y .= <<END;
- name: Test $j
if: matrix.task == '$j'
run: |
java -cp Classes $c/$j
END
}
my $f = writeFileUsingSavedToken $user, $repo, $wf, $y; # Upload workflow
lll "$f Ubuntu work flow for $repo";
}